Accessing the DataList footer in ASP.NET

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.
 
G

Guest

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
 
A

amiga500

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
 

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

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top