469,304 Members | 2,192 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,304 developers. It's quick & easy.

DataItem.Eval inside <FooterTemplate>

I am just wondering... can footertemplate hold data?

b/c i want to show the sum of my Invoice in footer template. How can i
do that? I could add the sum to the dataset like this:

SumColumn = new DataColumn("SumColumn",Double,"Sum(ItemTotal)")
ds.tables(0).columns.Add(SumColumn)

if i do:

<%#DataBinder.Eval(Container,"DataItem.SumColumn") %> inside the footer
template, i get nothing...

Any help?

Jul 22 '05 #1
5 8520
Hi,

Data could be binded in the footer template. This is possible.

Hope so,

<%# DataBinder.Eval(Container,"DataItem.SumColumn") %> this is wrong. The
right syntax is
<%# DataBinder.Eval(Container.DataItem,"SumColumn") %>

"tascien" wrote:
I am just wondering... can footertemplate hold data?

b/c i want to show the sum of my Invoice in footer template. How can i
do that? I could add the sum to the dataset like this:

SumColumn = new DataColumn("SumColumn",Double,"Sum(ItemTotal)")
ds.tables(0).columns.Add(SumColumn)

if i do:

<%#DataBinder.Eval(Container,"DataItem.SumColumn") %> inside the footer
template, i get nothing...

Any help?

Jul 22 '05 #2
The Syntax you suggested above fails to compile:

'DataItem' is not a member of 'System.Web.UI.Control'.

Tascien

Jul 22 '05 #3

Hi there,

You need to handle the DataGrid's ItemDataBound event. This event is raised
every time an item is bound to the data source. You can then have a variable
that adds up all the values in this event and display it in the footer by
handling the ItemCreated event. Check the documentation, the arguments of
these events include the item, so you can add a label control to display the
total at the footer.

Good luck!

--
Juan Romero
-----------------------------------------
The successful person has the habit of doing the things failures don't like
to do.
E.M. Gray
"tascien" wrote:
I am just wondering... can footertemplate hold data?

b/c i want to show the sum of my Invoice in footer template. How can i
do that? I could add the sum to the dataset like this:

SumColumn = new DataColumn("SumColumn",Double,"Sum(ItemTotal)")
ds.tables(0).columns.Add(SumColumn)

if i do:

<%#DataBinder.Eval(Container,"DataItem.SumColumn") %> inside the footer
template, i get nothing...

Any help?

Jul 22 '05 #4
Ahhhhhhhhhh... funny but this one seem to be working...:

<%#Ctype(Container.Parent,Object).DataSource(0)("I D") %>

funny... see below (but it will crash if the invoice contains no
items... ) :

<asp:Repeater id=Repeater2 DataSource='<%# GetSales() %>'
runat="server">

<ItemTemplate>
<%# DataBinder.Eval( Container, "DataItem.ID" ) %>
</ItemTemplate>

<FooterTemplate>
<%# Ctype(Container.Parent,Object).DataSource(0)("Sum" ) %>
</FooterTemplate>

</asp:Repeater>

Jul 22 '05 #5

As a general rule, I suggest you avoid doing runtime data binding. It is
much slower and not a good practice. It is preferable to do it in the
assembly so the code is compiled, fast, and easy to understand.
--
Juan Romero
-----------------------------------------
The successful person has the habit of doing the things failures don't like
to do.
E.M. Gray
"tascien" wrote:
Ahhhhhhhhhh... funny but this one seem to be working...:

<%#Ctype(Container.Parent,Object).DataSource(0)("I D") %>

funny... see below (but it will crash if the invoice contains no
items... ) :

<asp:Repeater id=Repeater2 DataSource='<%# GetSales() %>'
runat="server">

<ItemTemplate>
<%# DataBinder.Eval( Container, "DataItem.ID" ) %>
</ItemTemplate>

<FooterTemplate>
<%# Ctype(Container.Parent,Object).DataSource(0)("Sum" ) %>
</FooterTemplate>

</asp:Repeater>

Jul 22 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Leo Duran | last post: by
1 post views Thread by Jorge Loaiza Arango | last post: by
2 posts views Thread by Olivier Verdin | last post: by
5 posts views Thread by tascien | last post: by
reply views Thread by deathtospam | last post: by
1 post views Thread by David Lozzi | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by suresh191 | last post: by
reply views Thread by harlem98 | last post: by
1 post views Thread by Geralt96 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.