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
ataList 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
ataList>
</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?
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
<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
</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?