R
rn5a
How can I place a Label control in the FooterTemplate of a DataList
control?
I tried this
<script runat="server">
Sub Page_Load(obj As Object, ea As EventArgs)
Dim dblTotal As Double
Dim sqlReader As SqlDataReader
dblTotal = 'calling a function which returns a Double
sqlReader = 'calling another function which returns
SqlDataReader
dlCart.DataSource = sqlReader
dlCart.DataBind
lblTotal.Text = dblTotal
End Sub
</script>
<form runat="server">
<aspataList ID="dlCart" runat="server">
<HeaderTemplate>
<table>
<th>ID</th>
<th>Product</th>
<th>Unit Price</th>
</tr>
</HeaderTemplate>
<ItemTemplate>
<tr>
.........
</tr>
</ItemTemplate>
<FooterTemplate>
<tr>
<td colspan=2>TOTAL:</td>
<td><asp:Label ID="lblTotal" runat="server"/></td>
</tr>
</table>
</FooterTemplate>
</aspataList>
</form>
But it throws the error
Name 'lblTotal' is not declared.
pointing to
lblTotal.Text = dblTotal
How do I add a Label within the FooterTemplate of a DataList so that
the total can be displayed under the Unit Price column? Or is there any
other way by which I can display the total under the Unit Price column
in the DataList?
control?
I tried this
<script runat="server">
Sub Page_Load(obj As Object, ea As EventArgs)
Dim dblTotal As Double
Dim sqlReader As SqlDataReader
dblTotal = 'calling a function which returns a Double
sqlReader = 'calling another function which returns
SqlDataReader
dlCart.DataSource = sqlReader
dlCart.DataBind
lblTotal.Text = dblTotal
End Sub
</script>
<form runat="server">
<aspataList ID="dlCart" runat="server">
<HeaderTemplate>
<table>
<th>ID</th>
<th>Product</th>
<th>Unit Price</th>
</tr>
</HeaderTemplate>
<ItemTemplate>
<tr>
.........
</tr>
</ItemTemplate>
<FooterTemplate>
<tr>
<td colspan=2>TOTAL:</td>
<td><asp:Label ID="lblTotal" runat="server"/></td>
</tr>
</table>
</FooterTemplate>
</aspataList>
</form>
But it throws the error
Name 'lblTotal' is not declared.
pointing to
lblTotal.Text = dblTotal
How do I add a Label within the FooterTemplate of a DataList so that
the total can be displayed under the Unit Price column? Or is there any
other way by which I can display the total under the Unit Price column
in the DataList?