Showing posts with label displaying. Show all posts
Showing posts with label displaying. Show all posts

Thursday, March 22, 2012

Set length of container

Hi to anyone out there that is taking the time to read this. I'm new to
..net and any help given is appreciated.

I am displaying a datalist on a page and I want to limit the length of
the returned container.dataitem that is displayed to 39 characters. How
do i do this in asp.net? I can do this in classic asp by using the
len() function, but i'm a bit stuck on how to do it in asp.net.

Thanks for any help you can give, my code is below.

========================================
'code behind creating list

Dim SQLdata As String
Dim dDS As New DataSet()
SQLdata = "SELECT id, pagedata FROM tblContent WHERE level6 =
'" & sLev6 & "'"
sConn = "Provider=Microsoft.jet.OLEDB.4.0; Data Source=" &
dbPath & ";"

Dim myConnd As New OleDbConnection(sConn)
Dim myAdapterd As New OleDbDataAdapter(SQLdata, myConnd)
myConnd.Open()

Try
myAdapterd.Fill(dDS)
DLdata.DataSource = dDS.Tables(0).DefaultView
DLdata.DataBind()
Finally
myConnd.Close()
End Try

========================================
'code on aspx page displaying list

<asp:DataList ID="DLdata" runat="server" cssclass="DLdatagrid">
<ItemStyle CssClass="DLdata" />
<ItemTemplate>
<img src="http://pics.10026.com/?src=images/arrow.jpg" alt=""/> <a
href='pagedata.aspx?id=<%#DataBinder.Eval(Container.DataItem,
"id")%>'><%#DataBinder.Eval(Container.DataItem, "pagedata")%></a
</ItemTemplate>
</asp:DataListthe easiest way to do it is:

<%# left(DataBinder.Eval(Container.DataItem, "pagedata"), 39)%
Karl

--
http://www.openmymind.net/

<marcus.lecount@.googlemail.com> wrote in message
news:1138056537.361430.326800@.z14g2000cwz.googlegr oups.com...
> Hi to anyone out there that is taking the time to read this. I'm new to
> .net and any help given is appreciated.
> I am displaying a datalist on a page and I want to limit the length of
> the returned container.dataitem that is displayed to 39 characters. How
> do i do this in asp.net? I can do this in classic asp by using the
> len() function, but i'm a bit stuck on how to do it in asp.net.
> Thanks for any help you can give, my code is below.
> ========================================
> 'code behind creating list
> Dim SQLdata As String
> Dim dDS As New DataSet()
> SQLdata = "SELECT id, pagedata FROM tblContent WHERE level6 =
> '" & sLev6 & "'"
> sConn = "Provider=Microsoft.jet.OLEDB.4.0; Data Source=" &
> dbPath & ";"
> Dim myConnd As New OleDbConnection(sConn)
> Dim myAdapterd As New OleDbDataAdapter(SQLdata, myConnd)
> myConnd.Open()
> Try
> myAdapterd.Fill(dDS)
> DLdata.DataSource = dDS.Tables(0).DefaultView
> DLdata.DataBind()
> Finally
> myConnd.Close()
> End Try
> ========================================
> 'code on aspx page displaying list
> <asp:DataList ID="DLdata" runat="server" cssclass="DLdatagrid">
> <ItemStyle CssClass="DLdata" />
> <ItemTemplate>
> <img src="http://pics.10026.com/?src=images/arrow.jpg" alt=""/> <a
> href='pagedata.aspx?id=<%#DataBinder.Eval(Container.DataItem,
> "id")%>'><%#DataBinder.Eval(Container.DataItem, "pagedata")%></a>
> </ItemTemplate>
> </asp:DataList
Thanks Karl, I can't believe i missed that. Why do i always miss the
obvious?
Thanks for taking the time to answer, I appreciate your help.

Karl Seguin [MVP] wrote:
> the easiest way to do it is:
> <%# left(DataBinder.Eval(Container.DataItem, "pagedata"), 39)%>
> Karl
> --
> http://www.openmymind.net/
>
> <marcus.lecount@.googlemail.com> wrote in message
> news:1138056537.361430.326800@.z14g2000cwz.googlegr oups.com...
> > Hi to anyone out there that is taking the time to read this. I'm new to
> > .net and any help given is appreciated.
> > I am displaying a datalist on a page and I want to limit the length of
> > the returned container.dataitem that is displayed to 39 characters. How
> > do i do this in asp.net? I can do this in classic asp by using the
> > len() function, but i'm a bit stuck on how to do it in asp.net.
> > Thanks for any help you can give, my code is below.
> > ========================================
> > 'code behind creating list
> > Dim SQLdata As String
> > Dim dDS As New DataSet()
> > SQLdata = "SELECT id, pagedata FROM tblContent WHERE level6 =
> > '" & sLev6 & "'"
> > sConn = "Provider=Microsoft.jet.OLEDB.4.0; Data Source=" &
> > dbPath & ";"
> > Dim myConnd As New OleDbConnection(sConn)
> > Dim myAdapterd As New OleDbDataAdapter(SQLdata, myConnd)
> > myConnd.Open()
> > Try
> > myAdapterd.Fill(dDS)
> > DLdata.DataSource = dDS.Tables(0).DefaultView
> > DLdata.DataBind()
> > Finally
> > myConnd.Close()
> > End Try
> > ========================================
> > 'code on aspx page displaying list
> > <asp:DataList ID="DLdata" runat="server" cssclass="DLdatagrid">
> > <ItemStyle CssClass="DLdata" />
> > <ItemTemplate>
> > <img src="http://pics.10026.com/?src=images/arrow.jpg" alt=""/> <a
> > href='pagedata.aspx?id=<%#DataBinder.Eval(Container.DataItem,
> > "id")%>'><%#DataBinder.Eval(Container.DataItem, "pagedata")%></a>
> > </ItemTemplate>
> > </asp:DataList

Set length of container

Hi to anyone out there that is taking the time to read this. I'm new to
.net and any help given is appreciated.
I am displaying a datalist on a page and I want to limit the length of
the returned container.dataitem that is displayed to 39 characters. How
do i do this in asp.net? I can do this in classic asp by using the
len() function, but i'm a bit stuck on how to do it in asp.net.
Thanks for any help you can give, my code is below.
========================================
'code behind creating list
Dim SQLdata As String
Dim dDS As New DataSet()
SQLdata = "SELECT id, pagedata FROM tblContent WHERE level6 =
'" & sLev6 & "'"
sConn = "Provider=Microsoft.jet.OLEDB.4.0; Data Source=" &
dbPath & ";"
Dim myConnd As New OleDbConnection(sConn)
Dim myAdapterd As New OleDbDataAdapter(SQLdata, myConnd)
myConnd.Open()
Try
myAdapterd.Fill(dDS)
DLdata.DataSource = dDS.Tables(0).DefaultView
DLdata.DataBind()
Finally
myConnd.Close()
End Try
========================================
'code on aspx page displaying list
<asp:DataList ID="DLdata" runat="server" cssclass="DLdatagrid">
<ItemStyle CssClass="DLdata" />
<ItemTemplate>
<img src="http://pics.10026.com/?src=/library/images/arrow.jpg" alt=""/> <a
href='pagedata.aspx?id=<%#DataBinder.Eval(Container.DataItem,
"id")%>'><%#DataBinder.Eval(Container.DataItem, "pagedata")%></a>
</ItemTemplate>
</asp:DataList>the easiest way to do it is:
<%# left(DataBinder.Eval(Container.DataItem, "pagedata"), 39)%>
Karl
http://www.openmymind.net/
<marcus.lecount@.googlemail.com> wrote in message
news:1138056537.361430.326800@.z14g2000cwz.googlegroups.com...
> Hi to anyone out there that is taking the time to read this. I'm new to
> .net and any help given is appreciated.
> I am displaying a datalist on a page and I want to limit the length of
> the returned container.dataitem that is displayed to 39 characters. How
> do i do this in asp.net? I can do this in classic asp by using the
> len() function, but i'm a bit stuck on how to do it in asp.net.
> Thanks for any help you can give, my code is below.
> ========================================
> 'code behind creating list
> Dim SQLdata As String
> Dim dDS As New DataSet()
> SQLdata = "SELECT id, pagedata FROM tblContent WHERE level6 =
> '" & sLev6 & "'"
> sConn = "Provider=Microsoft.jet.OLEDB.4.0; Data Source=" &
> dbPath & ";"
> Dim myConnd As New OleDbConnection(sConn)
> Dim myAdapterd As New OleDbDataAdapter(SQLdata, myConnd)
> myConnd.Open()
> Try
> myAdapterd.Fill(dDS)
> DLdata.DataSource = dDS.Tables(0).DefaultView
> DLdata.DataBind()
> Finally
> myConnd.Close()
> End Try
> ========================================
> 'code on aspx page displaying list
> <asp:DataList ID="DLdata" runat="server" cssclass="DLdatagrid">
> <ItemStyle CssClass="DLdata" />
> <ItemTemplate>
> <img src="http://pics.10026.com/?src=/library/images/arrow.jpg" alt=""/> <a
> href='pagedata.aspx?id=<%#DataBinder.Eval(Container.DataItem,
> "id")%>'><%#DataBinder.Eval(Container.DataItem, "pagedata")%></a>
> </ItemTemplate>
> </asp:DataList>
>
Thanks Karl, I can't believe i missed that. Why do i always miss the
obvious?
Thanks for taking the time to answer, I appreciate your help.
Karl Seguin [MVP] wrote:
> the easiest way to do it is:
> <%# left(DataBinder.Eval(Container.DataItem, "pagedata"), 39)%>
> Karl
> --
> http://www.openmymind.net/
>
> <marcus.lecount@.googlemail.com> wrote in message
> news:1138056537.361430.326800@.z14g2000cwz.googlegroups.com...