|
-
Aug 22nd, 2003, 02:08 PM
#1
Thread Starter
New Member
asp.net formatting data using the repeater control
I'm having trouble with formatting the data from my db.
I need to format the data before it is written to the browser. when itry to format the <%# databinder.eval(container.dataItem, "SessionTime") %> tags i get an error
the seesionTime is a datetime field on my DB and is coming as 12/30/1899 12:30:00 AM I only need the "12:30:00AM" part.
and the LocationID field needs to be UCased
simple things (I thought)
thanks
here's my code (HTML)
'****************************************
<asp:repeater id="Repeater1" runat="server">
<HeaderTemplate>
<table width="90%" cellspacing="0" cellpadding="3" border="0" class="tableborder" align="center">
<tr bgcolor="#cc3300">
<td class="tabletitle">Status</td>
<td class="tabletitle">Date</td>
<td class="tabletitle">Course Title</td>
<td class="tabletitle">Location</td>
<td class="tabletitle">Times</td>
</tr>
</HeaderTemplate>
<ItemTemplate>
<tr bgcolor="#e6e6e6">
<td><asp:Label id="Label2" runat="server">Label</asp:Label><%# databinder.eval(container.dataItem, "Sessionid") %></td>
<td><%# databinder.eval(container.dataItem, "SessionTime") %>
-
<%# databinder.eval(container.dataItem, "SessionTimeEnd") %>
</td>
<td><%# databinder.eval(container.dataItem, "CourseID") %></td>
<td><%# databinder.eval(container.dataItem, "SessionDate") %></td>
<td><%# databinder.eval(container.dataItem, "LocationID") %></td>
</tr>
</ItemTemplate>
<AlternatingItemTemplate>
<tr bgcolor="#ffffff">
<td><%# databinder.eval(container.dataItem, "Sessionid") %></td>
<td><%# databinder.eval(container.dataItem, "SessionTime") %>
-
<%# databinder.eval(container.dataItem, "SessionTimeEnd") %>
</td>
<td><%# databinder.eval(container.dataItem, "CourseID") %></td>
<td><%# databinder.eval(container.dataItem, "SessionDate") %></td>
<td><%# databinder.eval(container.dataItem, "LocationID") %></td>
</tr>
</AlternatingItemTemplate>
<FooterTemplate>
</TABLE>
</FooterTemplate> </asp:repeater>
'****************************
'code behind code
'****************************
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Start check session state
Dim check As New checkstatus()
check.checklogin()
'end check session state
Dim strConnect As String
strConnect = SqlConnection1.ConnectionString
Dim Query As String
Query = "SELECT SessionDate, SessionTime, SessionID, SessionTimeEnd, CourseID, LocationID FROM Sessions"
' Open the Connection
Dim ConCheckForClasses As New System.Data.SqlClient.SqlConnection(strConnect)
ConCheckForClasses.Open()
' Try to execute the SQL command using a READER
Dim CheckForClasses As New System.Data.SqlClient.SqlCommand(Query, ConCheckForClasses)
Dim rdrCheckForClasses As System.Data.SqlClient.SqlDataReader = CheckForClasses.ExecuteReader()
' If .read is true then the row(s) were found
Repeater1.DataSource = rdrCheckForClasses
Repeater1.DataBind()
rdrCheckForClasses.Close()
End Sub
'********************
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|