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
0
mvillagr
9/9/2004 6:59:54 PM
asp.net.presentation-controls 72751 articles. 3 followers. Follow

2 Replies
518 Views

Similar Articles

[PageSpeed] 51

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 column
Sub grid_ItemDataBound(ByVal sender As Object, ByVal e As DataGridItemEventArgs)
If e.Item.ItemType = ListItemType.Item Or e.Item.ItemType = ListItemType.AlternatingItem Then
runningSum += Convert.ToDouble(DataBinder.Eval(e.Item.DataItem, "ClaimAmount"))
End If
If e.Item.ItemType = ListItemType.Footer Then
e.Item.Attributes.Add("onmouseover", "this.style.backgroundColor='Green'")
e.Item.Cells(5).Text = "Total:&nbsp;" & String.Format("{0:c}", runningSum) & ""
lblClaimTotal.Text = "Total:&nbsp;" & String.Format("{0:c}", runningSum) & "<br>"
End If
End Sub

Thanks,
javaJones
0
javaJones
9/9/2004 7:58:29 PM
Thank's But, this example...¿Only function with the AutoGenerateColumns is False?

I see this in the other page.
Thank's
Mauricio Villagrán
0
mvillagr
9/9/2004 8:46:15 PM
Reply:

Similar Artilces:

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

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 : http://alvinzc.blogspot.com...

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 asp.net +vb.net.                     may i knw hw can i do this.. plz write the code.. thanks.         Hi, do like this..suppose u have,        string ProductPrice = ...

Sum of datagrid column in footer
I'm trying to total the values of a column in my datagrid and then display that total in the footer of the datagrid. I'm very new to ASP.NET and have looked but not found the answer. I read the article at http://www.extremeexperts.com/Net/Articles/AddingControlstoFooter.aspx but it appeared to be more of a static solution. Any assistance or direction is appreciated. - J Take a look at view post 362074Darren That is the post where I got the referring web site. But, I did not see an example that added the column values. check this one***********************Dinakar NethiLife is shor...

Displaying image in a column of a datagrid control
Hi Experts, How can i display an image in a column of a datagrid control? On clicking that image i want to redirect to another screen based on the row selected. Also how should i open an popup screen by clicking the hyperlink column of a datagrid control. It is similar to a message board forum.(viewing all the messages posted with details) Thanks in advance. Hi, you can take a look at this article. There are many others around when you google for it. Grz, Kris.Read my blog. Handy Firefox plugins for web developers.Workaround for non working Mark as answer buttons....

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

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" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <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...

Hiding datagrid column when sum in footer is 0
Hi,  I am trying to hide every column when the sum in the footer is 0. Here is the code so far. Any ideas as to how this thing could be accomplished? 1 Private Sub dgReport_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs) Handles dgReport.ItemDataBound2 3 If e.Item.ItemType = ListItemType.Item Or e.Item.ItemType = ListItemType.AlternatingItem Then4 5 For i = 3 To e.Item.Cells.Count - 16 7 If Trim(e.Item.Cells(i).Text) <> "&nbsp;" Then 8 ...

Display sum of times in datagrid footer
Hi, This is probably simple but I'm obviously overlooking something. I have a datagrid displaying data pulled from SQL. One fo the DG fields is called "duration" and shows the result of time1 - time2 which is done in the SQL statement. This all works fine but now I am trying to show the totals in a DG footer using the following code:  Protected Sub showTotals(ByVal sender As Object, ByVal e As DataGridItemEventArgs)        If e.Item.ItemType = ListItemType.Item Or e.Item.ItemType = ListItemType.AlternatingItem Then   &nbs...

DataGrid etc does not display when using VS.NET server controls
This thing is driving me nuts! I know you should be able to do it with code but I want to be able to drag a dataadapter onto a page, set up the dataset from that and bind it to a datagrid without writing a line of code. Everytime I do it whether I am using a remote SQL Server or a local MSDE for the datasouce all I get is a blank page. The source contains the form and the __VIEWSTATE and that is it. If I add in the pageload codebehind datagrid1.databind() then I get the column headings and that is all. Any ideas? Regards, DaveB You always have to call DataBind, that's for sure....

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

column header to span two columns in a datagrid display
Is it possible for a column header to span two columns? If so how would this be done? Thanks In the ItemDataBound (or ItemCreated) check if Item is of type Header and if so - define the colspan property of the Cell object which you want to define the Colspan for and delete the next Cell from hte DataGridItem CheersBug [MCSD] Is it possible to span header column in design view only. using some kind of CSS. I'm using ASP,NET 3.5 and GridView...

Web resources about - How to Displaying the Sum of a Column in the Datagrid Footer - asp.net.presentation-controls

List of mammals displaying homosexual behavior - Wikipedia, the free encyclopedia
For these mammals, there is documented evidence of homosexual behavior of one or more of the following kinds: sexual behavior , courtship , affection ...

Facebook Displaying Page Insights On Page Admins’ Personal Pages?
Some Facebook page administrators are seeing modules on their personal pages displaying page insights ad, campaign , and like totals for pages ...

Facebook Displaying Unread Messages from Pages in a New Updates Module
Facebook is displaying a new “Updates” sidebar module which shows some users unread messages sent to them by Pages. Users will see the Updates ...

Don Lemon Holds Up Sign Displaying the N-Word, Uncensored, on Air CNN Live - YouTube
Don Lemon Holds Up Sign Displaying the N-Word, Uncensored, on Air Lemon held up a Confederate flag first before holding up the sign. He asked, ...

Hazelwood coal mine fire: Morwell residents displaying symptoms similar to cigarette smokers, expert ...
An expert says some locals near Victoria's Hazelwood mine fire have symptoms similar to cigarette smokers.

Police accused of displaying fake G20 weapons
Toronto's top police officer misled the public by displaying fake weapons used in a medieval-themed role-playing game to help justify their actions ...

No charges for U.S. host for displaying high-capacity magazine on TV
NBC television journalist David Gregory won't face charges for displaying a high-capacity ammunition magazine on his "Meet the Press" news program ...

Jays' Escobar suspended three games for displaying slur
Toronto Blue Jays shortstop Yunel Escobar has been suspended three games for displaying a homophobic slur on his eye-black during a game on Saturday. ...

Google Play Store now displaying age-based ratings
We reported back in May that Google was adding age-based ratings to all apps in the Play Store as determined by the International Age Rating ...

Apple displaying Ferraris & other cars at WWDC hinting at CarPlay announcements
... 2014 Filed under: AAPL Company , iOS Continue reading more about AAPL Company and iOS at 9to5Mac . What do you think? Discuss "Apple displaying ...

Resources last updated: 12/13/2015 5:18:12 PM