Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

working with a datalist

Status
Not open for further replies.

sthmpsn1

MIS
Sep 26, 2001
456
US
I have the following code which I use to fill my datalist.

selectCMD1 = New SqlCommand()
selectCMD1.Connection = dbconn
selectCMD1.CommandTimeout = 30
selectCMD1.CommandText = "Select loginID, entity, amount, CONVERT( char(10), dates, 101), year from memberships where loginID = '" & empDS.tables("employeeinfo").Rows(0).Item("loginID") & "'"
empDA.SelectCommand = selectCMD1
dbconn.Open()
empDA.Fill(empDS, "memberships")
memberinfo.DataSource = empDS.Tables("memberships")
memberinfo.DataBind()
dbconn.Close()

I have the following list I create using this code.

<asp:datalist ID=&quot;memberinfo&quot; BorderColor=&quot;#000000&quot; BorderWidth=&quot;0&quot; CellPadding=&quot;5&quot; CellSpacing=&quot;5&quot; CssClass=&quot;apartmenttable&quot; ForeColor=&quot;#0000CC&quot; runat=&quot;server&quot;>
<headertemplate>
<td align=&quot;center&quot; width=&quot;100&quot; class=&quot;apartmentwhite&quot;>
Date
</td>
<td align=&quot;center&quot; width=&quot;100&quot; class=&quot;apartmentwhite&quot;>
Entity
</td>
<td align=&quot;center&quot; width=&quot;100&quot; class=&quot;apartmentwhite&quot;>
Amount
</td>
</headertemplate>
<itemtemplate>
<td align=&quot;center&quot; width=&quot;100&quot; class=&quot;apartmentinside&quot;>
<%# Container.DataItem( &quot;dates&quot; ) %>
</td>
<td align=&quot;center&quot; width=&quot;100&quot; class=&quot;apartmentinside&quot;>
<%# Container.DataItem( &quot;entity&quot; ) %>
</td>
<td align=&quot;center&quot; width=&quot;100&quot; class=&quot;apartmentinside&quot;>$
<%# Container.DataItem( &quot;amount&quot; ) %>
</td>
</itemtemplate>
</asp:datalist></p>

Right now I get an error saying

dates is neither a DataColumn nor a DataRelation for table memberships. Any ideas how to solve this. I am sure it is because of my convert statement
 
just put an as after all the convert stuff
eg.
selectCMD1.CommandText = &quot;Select loginID, entity, amount, CONVERT( char(10), dates, 101) as dates, year from memberships where loginID = '&quot; & empDS.tables(&quot;employeeinfo&quot;).Rows(0).Item(&quot;loginID&quot;) & &quot;'&quot;

HTH
That'l do donkey, that'l do
[bravo] Mark
 
Thanks man, I figured I was missing it, but I got the same thing to work by using this

<%# format(Container.DataItem( &quot;dates&quot; ).date) %>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top