472,796 Members | 1,488 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,796 software developers and data experts.

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 8655
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Leo Duran | last post by:
Hi, I am working on an app right now that makes extensive use of the DataList control. I chose the DataList because I need to do multi row formatting. I am using it like so.
1
by: Jorge Loaiza Arango | last post by:
Hi group, When I have TextBox1 in the <ItemTemplate> of Datagrid1, I can to access the propierties using: dim myTBox as TextBox = Datagrid1.Item(row).FindControl("TextBox1") but, if it is...
1
by: CJM | last post by:
I've copied (& modified) some code from MSDN which uses a Repeater control, but I'm getting an error: Unexpected end of file looking for </HeaderTemplate> As far as I can see I've not made an...
2
by: Olivier Verdin | last post by:
Hi, It seems that it is not possible to use <il> tag inside an asp.net repeater. Is there any way to overcome this difficulty? Thanks, Olivier
3
by: webserverpete | last post by:
I would like to have multiple <td> in a repeater control. The below code does not work: <asp:Repeater ID="Repeater1" runat="server" DataSourceID="SqlDataSource1" DataMember="DefaultView">...
5
by: tascien | last post by:
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 =...
0
by: deathtospam | last post by:
A few weeks ago, I created a Classic ASP page that connects to a machine with SQL Server installed on it, prompts the user to select a database on that server, then lists all of user-created stored...
1
by: David Lozzi | last post by:
Howdy, I have a datalist which is displaying a list of categories and their associated sub categories in secondary datalists. Works great in a single column. Unfortunaly when i switch it to...
0
by: Jeff | last post by:
hi asp.net 2.0 I have a GridView which in it's FooterTemplate contain textboxes for adding new rows to the GridView. I thought that was cool, until I tested the GridView without any data....
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: erikbower65 | last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps: 1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal. 2. Connect to...
0
linyimin
by: linyimin | last post by:
Spring Startup Analyzer generates an interactive Spring application startup report that lets you understand what contributes to the application startup time and helps to optimize it. Support for...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Sept 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Taofi | last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same This are my field names ID, Budgeted, Actual, Status and Differences ...
14
DJRhino1175
by: DJRhino1175 | last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this - If...
0
by: Rina0 | last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
0
by: lllomh | last post by:
How does React native implement an English player?
0
by: Mushico | last post by:
How to calculate date of retirement from date of birth

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.