Re: label in footertemplate of datagrid
- From: "Eliyahu Goldin" <REMOVEALLCAPITALSeEgGoldDinN@xxxxxxxxxxxx>
- Date: Sun, 1 Oct 2006 13:58:40 +0200
<asp:DataList ID="dlCart" runat="server"
OnItemDataBound="dlCart_ItemDataBound">
In the script:
Sub dlCart_ItemDataBound(sender As Object, e As DataListItemEventArgs)
If e.Item.ItemType = ListItemType.Footer
Dim dblTotal As Double
dblTotal = 'calling a function which returns a Double
Dim TotalLabel As Label = CType(e.Item.FindControl("lblTotal"),
Label)
TotalLabel .Text = dblTotal
End If
End Sub
--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]
<rn5a@xxxxxxxxxxxxxx> wrote in message
news:1159698485.717845.280120@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Eliyahu, could you please show me a small example of what you have
suggested? I haven't done anything like that anytime.
Eliyahu Goldin wrote:
Handle ItemDataBound event. Detect the footer item by the ItemType. Use
FindControl ("lblTotal") to locate the label inside the footer item.
--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]
<rn5a@xxxxxxxxxxxxxx> wrote in message
news:1159696793.107694.146910@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
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">
<asp:DataList 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>
</asp:DataList>
</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?
.
- Follow-Ups:
- Re: label in footertemplate of datagrid
- From: rn5a
- Re: label in footertemplate of datagrid
- References:
- label in footertemplate of datagrid
- From: rn5a
- Re: label in footertemplate of datagrid
- From: Eliyahu Goldin
- Re: label in footertemplate of datagrid
- From: rn5a
- label in footertemplate of datagrid
- Prev by Date: Use Request
- Next by Date: Re: Use Request
- Previous by thread: Re: label in footertemplate of datagrid
- Next by thread: Re: label in footertemplate of datagrid
- Index(es):
Relevant Pages
|