Visual Studio .NET - Sum(column) of gridView in asp.net 2.0 c#

Asked By abc V on 30-Nov-06 02:54 PM

Hi All,

I want to get the sum of a column in a gridView at the bottom Row so that I don't need to add up all the columns..... previously i used to add it in the stored procedure i used to get the data to the grid but this time the stored procedure uses a bulky view so didnt want to mess with it.... Please help me. Actually I could find the sum of the columns in the gridView but only when the paging was not enabled. i.e i can find the sum of the column present in that page of the grid but not when the paging is enabled... Hope i am clear

so i need the sum of the all columns when the paging is enabled .

Thanks in advance...

Display Sum Total in the Footer of the GridView Control

K Pravin Kumar Reddy replied to abc V on 01-Dec-06 06:22 AM

check out example here

http://aspalliance.com/782_CodeSnip_How_to_Display_Sum_Total_in_the_Footer_of_the_GridView_Control

http://authors.aspalliance.com/aspxtreme/sys/web/ui/webcontrols/demos/gridviewrowcreatedrowdatabound.aspx

http://msdn2.microsoft.com/en-us/library/ms972833.aspx

When the Paging=True then it gives the sum of the column in that page but i need the overall Sum

abc V replied to K Pravin Kumar Reddy on 01-Dec-06 11:31 AM

But I need the sum on the page when the paging is set to true and still get the total sum

of the column data visible in that Page. where as I need the sum of the total columns in ann the pages... :( Hope i am Clear......

Thanks a lot for u r response...

Compute

F Cali replied to abc V on 02-Dec-06 11:58 PM

Since you are getting your data from a stored procedure, you can compute for the sum of any column using the COMPUTE clause of the SELECT statement.  As an example, here's how to get all records from the Order Details table as well as getting the sum of the Quantity column:

SELECT *
FROM [Order Details]
COMPUTE SUM(Quantity)

http://www.sql-server-helper.com