473,387 Members | 1,669 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 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 8699
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....
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.