SqlDataAdapter & Label

R

rn5a

One of the columns in a SQL Server 2005 DB table is named 'OrderDate'
which stores the date & time on which an order has been placed. Since
the 'OrderDate' of a particular order will be the same, I want to
display the 'OrderDate' in a Label control & the rest of the records
should be displayed in a DataList. This is how I approached it:

<script runat="server">
Sub Page_Load(ByVal obj As Object, ByVal ea As EventArgs)
Dim dSet As DataSet
Dim sqlConn As SqlConnection
Dim sqlDapter As SqlDataAdapter

sqlConn = New SqlConnection(".....")
sqlDapter = New SqlDataAdapter("SELECT * FROM Orders WHERE
OrderID=6", sqlConn)

dSet = New DataSet()
sqlDapter.Fill(dSet, "Orders")

DataListOrder.DataSource = dSet.Tables("Orders").DefaultView
DataListOrder.DataBind()
End Sub
</script>

<form runat="server">
<asp:Label ID="lblOrderDate" runat="server"/>

<asp:DataList ID="DataListOrder" runat="server">
<HeaderTemplate>
<table border=2>
.......
</HeaderTemplate>
<ItemTemplate>
<tr>
<td><%# Container.DataItem("ProductName") %></td>
<td><%# Container.DataItem("Category") %></td>
<td><%# Container.DataItem("Price") %></td>
</tr>
</ItemTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
</asp:DataList>
</form>

The records under the columns 'ProductName', 'Category' & 'Price' in
the DB table will get looped automatically & will get displayed in the
DataList but how do I display the 'OrderDate' corresponding to
OrderID=6 in the Label control?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

DataBind 1
DataBind In ItemDataBound Event 1
IsPostBack 4
DB Value in Label 1
Show "No Records Found" Message 1
ViewState? 1
DropDownList DataGrid 1
Display DB Records in DataList? 1

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,058
Latest member
QQXCharlot

Latest Threads

Top