How Do I Display Sum Of Repeater Columns In Footer?

Hi All!

I'm trying to calculate the sum of product prices that are displayed in my ASP.NET Repeater.
I'm coding with C#.
Any ideas or article links on how to accomplish this?
Probably is easy but I'm somewhat new to the dotnet world.
Thanks for your help! Please C# answers only. I don't know vb at all.
11/16/2004 7:41:36 PM 72751 articles. 3 followers. Follow

3 Replies

Similar Articles

[PageSpeed] 37

Essentially you are going to create a variable in class scope, and then in the ItemDataBound event for the Repeater, you'll add the current record's value to this variable for Items and AlternatingItems, and then for the Footer, display it.  Something like:

int runningTotal = 0;
// event handler for ItemDataBound
private void myRepeater_ItemDataBound(object sender, EventArgs e)
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
runningTotal += Convert.ToInt32(DataBinder.Eval(e.Item.DataItem, "databaseField"));
else if (e.Item.ItemType == ListItemType.Footer)
((Label) e.Item.FindControl("labelID").Text = string.Format("{0:c}", runningTotal);

This assumes in your <FooterTemplate> you have a Label with ID labelID.
Happy Programming!

-- Scott Mitchell
11/17/2004 5:23:56 AM
Thanks Much, that did the trick!

God I love!
11/17/2004 2:05:35 PM
Mr Rolla comes through once again
In this world there are 10 types of people, those that know binary and those who don't.
11/17/2004 4:11:50 PM

Similar Artilces:

Sum of Columns in Repeater Control
Hello Everyone, I am currently working on a project in .NET framework 1.1 and using the Visual Studios 2003 IDK. In my project I have a repeater control with 10 columns. Out of those 10, I need 8 to be sub-totaled in the bottom of each. What is the easiest way to calculate the sum of the values that are shown in each column dynamically? Thank you and I will highly appreciate your help in this matter. Also, I am a new developer so please be very simplistic in your reply. I'm still in the learning process. Thanks again.  Regards,Omair    Hi omaleem , In thi...

How to Displaying the Sum of a Column in the Datagrid Footer
Hi all. Im need Displaying the Sum of a Column in the Datagrid Footer, but the property AutoGenerateColumns is True. ¿How to do This? Thanks to all. Mauricio Villagrán Try this: <asp:label id="lblClaimTotal" runat="server" ></asp:label> <asp:datagrid id="DataGrid1" runat="server" AllowPaging="False" DataKeyField="ID" OnItemDataBound="grid_ItemDataBound" > and in the code behind page 'Routine to highlight selected grid row. And to show total of claim amount colum...

How to Display Sum Total in the Footer of the GridView Control
I found an answer for this question. "How to Display Sum Total in the Footer of the GridView Control" But this resource was written in aspx source. I wanted to convert this to "Code Behind" style but it's not working out. Please help me. [Original working source]  aspx <%@ Page Language="VB" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" ""> <script runat="server"> Dim TotalUnitPrice As Decimal = 0.0 Function GetUnitPrice(ByVal Price As Decimal) As Decimal TotalUnitPrice += Price ...

Summing up columns in footer of Data Grid Control
I'm trying to sum up the values from the collumns that i have in a certain data grid. I have 2 options: 1. I have a stored proc that I have written that can sum up the values (how can I place the values from that stored proc into the footer of a particluar Data grid). 2.  How can i sum up the values from w/n the data grid.  (from the ItemDataBind).   Examples from either is greatly appricated: Thanks in advance everyone. Regards, RB    check this ***********************Dinakar NethiLife is short. Enjoy it.*********************** Thanks for poin...

displaying difference of two columns in repeater control
how to display the difference of two coulmns having float values in a repeater control? Hi,You can get the difference from sql query like : select (a-b) as result.Then you can bing the same column field in Repeater control. Always "Mark as Answer" the Post That Solves the problem.Because It helps others to find the solution. Mohammad Hussain Hi,There is many way to do this... 1) Using foreach {} loop you go through each and every column and in that loop write business logic such that when wanted two column value get sum. Value of the cell is ret...

Can a Repeater Control display records in 2 Columns?
I am trying to make use of some empty space on my page that displays in a Repeater control a bunch of records that only have a small amount of data to display in 3 Columns. I am trying to figure out if I can split 2 records into 2 columns side by side then repeat the next 2 records below the first 2. So essentially I want the repeater to repeat twice horizontally, then step vertically down one line and repeat 2 more records horizontally. ie. Record 1 Record 2 Record 3 Record 4 Record 5 Record 6 and so on... Anything would be great and yes no maybe so, or a li...

How to Display Repeater control like table with rows and columns
I am getting display of repeater Items like NameAddress NameAddress NameAddress NameAddress...................Like this 50 in number So I want display to look like Name            Name      NameAddress      Address     Address Name            Name      NameAddress      Address     Address Name       &nb...

How to Display Sum Total in the Footer of the GridView Control using boundfield, templatefield
 This vb code compiles find but give me runtime error. Please help me!    Dim TotalUnitPrice As Decimal = 0.0 Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Dim col1 As BoundField = New BoundField() Dim col2 As BoundField = New BoundField() Dim col3 As TemplateField = New TemplateField() col1.DataField = "Productid" col1.HeaderText = "Product Id" col1.SortExpression = "Productid" col2.DataField = "ProductName" col2.HeaderText = "Product N...

Re: How to control the columns displayed on a .net page depending on the page the user is coming from
  Hi all,    I have got two pages on wy website which contains a form to submit data into the same database. The two pages have also got a link to view the submitted data. The challenge I have got at the moment is, I want to be able to control columns the users see depending on the which of the two pages they are coming from. I know I can simply create two more separate pages but I don't want to do that. I feel I can be clever and achieve this with a conditional statement but to be honest, I don't know how to go about this. Could you please help me on thsi? Bas...

How to display the sum of a column at the footor of the datagrid column
HI, Any idea how I can display the Sum of any column at the Footor of that Column. HighOnCodingWanna get high! Hi, Take a look @ Displaying Column Summary Information in the Footer HTH K B ShajudeenAreYaar.comDubai, United Arab Emirates....

Dividing one column to 4 columns in the Repeater control
Hi Folks, The following is my Repeater-Control code that providing a list of 20 companies names. I'm getting all of the data in one long column and I would like to divide this one column to 4 columns. Is it possible? how can I do it in my code: <asp:Repeater ID="catlist" runat="server"> <HeaderTemplate> <table border="0" cellpadding="0" cellspacing="0" width="100%"> <tr> ...

display the sum of two datagrid columns into third column
hi... there..     i have a datagrid with columns named Price ,Quantity and total. now in the total column i  wanna display the prices which comes by multiplyiing the price and quantity (like  total=Price * quantity). I'm workin in                     may i knw hw can i do this.. plz write the code.. thanks.         Hi, do like this..suppose u have,        string ProductPrice = ...

How to display column total of numeric columns in the datagrid footer
I able to connect Datagrid control to ADO.Net for pulling data. But I can not able to display total of a numeric field column in the Datagrid footer. Is it possible? How? Please tell me any one. Hi, please read up Displaying Column Summary Information in the Footer and HOW TO: Create a Summary Row for a DataGrid in ASP.NETHope this helps..Alvin ChooiMicrosoft ASP.NETâ„¢ Enthusiast v1.1 / v2.0, Malaysia Blog :

Repeater control in another repeater control
Hi, I want Repeater control in another repeater control but it is not working Code : <asp:Repeater ID=CourseMaster Runat=server > <ItemTemplate> <table border=0 cellpadding=0 cellspacing=0 style="font-family:tahoma;font-size:12"> <tr> <td >&nbsp;<b</b></td> </tr> <tr> <td> <asp:repeater ID="CourseDetails" Runat=server> <ItemTemplate> <tab...

Web resources about - How Do I Display Sum Of Repeater Columns In Footer? -

Repeaters - Wikipedia, the free encyclopedia
Kyle Halsted, Sonia Logan, and Michael Weeks are inmates at a rehabilitation facility. Bob Simpson, the administrator, tasks them with apologizing ...

Repeater Locator on the App Store on iTunes
Get Repeater Locator on the App Store. See screenshots and ratings, and read customer reviews.

Consumers warned to beware of illegal mobile phone repeaters
Use of devices sold online as legitimate solution is in fact dangerous and can land you in jail, regulator warns.

Grim repeater: HIV on the rise
CANDLES flicker in the chilly night air as Jesse Hooper appears on the giant cinema screen overlooking Melbourne&#8217;s Federation Square. He&#8217;s ...

Telstra suspects underbelly of illegal repeaters
'Tens' busted each year. Telstra engineers suspect a "vast" undercurrent of illegal repeaters are causing issues for the carrier's Next G mobile ...

Hands on: Cel-Fi mobile repeater
If your home is a mobile blackspot then a Cel-Fi mobile repeater might help you stay connected.

Amped Wireless R20000G, SR20000G, and UA2000: Routers, Repeaters, and Adapters
... and throughput when pointed at your wireless router/access point. Rounding out the review, Amped sent a third product, their SR20000G repeater, ...

Extending your network's range with a wireless repeater
... your cable modem has to live on one end of your house, leaving the other far away from your wireless signal. That's where a wireless repeater ...

Brooke Mueller, Lindsay Lohan, Demi Moore: Celebrity Rehab Repeaters (PHOTOS)
Brooke Mueller is off the wagon again, shockingly returning to rehab for the 19th time. Although that number is extreme, rehab has unfortunately ...

Computer networking: wireless networks (wifi), routers, repeaters & more - CNET Reviews
Computer networking reviews and ratings, video reviews, user opinions, most popular network hardware, wireless network buying guides, prices, ...

Resources last updated: 1/13/2016 12:57:44 AM