Accessing the DataList footer in ASP.NET

  • Thread starter Thread starter amiga500
  • Start date Start date
A

amiga500

Hello,

I have a DataList that displays the item information and total price
of each time but I want to add a footer with a complete subtotal. I am
using ASP.NET (VB) however I don't know how to call a footer in my
code, below is the code I have added:

CType(e.Item.FindControl("lblFooterTotal"), Label).Text =
CompleteTotal

However I get this "Object reference not set to an instance of an
object." because it cannot find the footer. Here is the HTML code:

<FooterTemplate>
<asp:Label ID ="lblCompleteTotal" runat =
"server">Total:</asp:Label>
<asp:Label ID="lblFooterTotal" runat="server"
Text="0"></asp:Label>
</FooterTemplate>

Can someone please help me in this regard? Thanks in advance.
 
Hi,

I assuming , you written "CType(e.Item.FindControl("lblFooterTotal"),
Label).Text =
CompleteTotal" code in DataList_ItemDataBound.

Try this
If e.Item.ItemType = ListItemType.Footer Then
CType(e.Item.FindControl("lblTotalPercentage"), Label) ).Text =
CompleteTotal
End If
 
Hi,

I assuming , you written "CType(e.Item.FindControl("lblFooterTotal"),
Label).Text =
CompleteTotal" code in DataList_ItemDataBound.

Try this
If e.Item.ItemType = ListItemType.Footer Then
CType(e.Item.FindControl("lblTotalPercentage"), Label) ).Text =
CompleteTotal
End If
Thank you guys, much appreciate it :D
 
Back
Top