Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Accessing the DataList footer in ASP.NET

Reply
Thread Tools

Accessing the DataList footer in ASP.NET

 
 
amiga500@gmail.com
Guest
Posts: n/a
 
      10-16-2007
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.

 
Reply With Quote
 
 
 
 
Eliyahu Goldin
Guest
Posts: n/a
 
      10-16-2007
Check if e.Item.ItemType = ListItemType.Footer before trying to access
footer controls.

--
Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net


<(E-Mail Removed)> wrote in message
news:(E-Mail Removed) ups.com...
> 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.
>



 
Reply With Quote
 
 
 
 
=?Utf-8?B?VWp2YWwgU2hhaA==?=
Guest
Posts: n/a
 
      10-16-2007
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

"(E-Mail Removed)" wrote:

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

 
Reply With Quote
 
amiga500@gmail.com
Guest
Posts: n/a
 
      10-16-2007
On Oct 16, 10:44 am, Ujval Shah <(E-Mail Removed)>
wrote:
> 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
>
> "(E-Mail Removed)" wrote:
> > 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:

>

Thank you guys, much appreciate it

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



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Any way to reorder how a datagrid is drawn (header/footer/items vs.header/items/footer)? Henrik ASP .Net Datagrid Control 1 07-06-2006 12:23 AM
Setting up a datalist control - Item_DataBound for a datalist in a datalist Nevyn Twyll ASP .Net 8 09-09-2004 10:13 PM
Button in Datalist Footer Error... Chris ASP .Net 3 08-11-2004 04:14 AM
Accessing controls within a datalist footer template Paul Maidment ASP .Net 1 08-07-2003 04:39 PM
Datalist - how (if) to use a sub variable or session variable in the footer? KathyB ASP .Net 1 07-17-2003 01:35 AM



Advertisments