Click here to Skip to main content
15,886,806 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello,

I have a SQL table and i am performing some Count on the column values and then displaying it using ASP.NET's gridview to the frontend.
I am using below SQL query
select currentstepname,   
sum(case when bundledtype in ('1','3','5') then 1 else 0 end) Count1,  
sum(case when bundledtype in ('2','4','5') then 1 else 0 end) Count2,  
sum(case when currentstepname in ('Decider','Checker') then 1 else 0 end) Count3,  
count(*) as GrandTotal,
from table1   
where currentstepname in ('EV Bucket','IV Bucket')  
group by currentstepname  
SQL



Now what i want is to get the total sum of each of Alias columns aswell and show it as the final row of the gridview.
What i am currently seeing at the GridView is as follows.

|CurrentStepName | Count1 | Count2 | Count3 | GrandTotal
Decider -------------- 8---------- 0 ------- 0------------ 8
Checker--------------- 4 --------- 0 ------- 0 ----------- 4
EVBucket-------------- 0--------- 20------- 14----------- 34
IVBucket-------------- 0---------- 10------ 5 ----------- 15
TotalCount---------12-------30-----------19------------61


In the above gridview i want the Bold Line (TotalCount) to be added. It counts the value of all the column values.
I hope i have made myself clear.

Looking forward to your help
Thanks a ton,

What I have tried:

Searcher google but could not find a similar problem
Posted
Updated 22-Feb-17 20:37pm

1 solution

If i understand you well, you want to display summary row for a datagrid. If so, please check this:
HOW TO: Create a Summary Row for a DataGrid in ASP.NET by Using Visual C# .NET[^]
Tutorial 15: Displaying Summary Information in the GridView's Footer[^]
 
Share this answer
 
Comments
Faran Saleem 23-Feb-17 3:20am    
Thanks a ton, it worked..
Maciej Los 23-Feb-17 10:28am    
You're very welcome.
Cheers,
Maciej
Karthik_Mahalingam 23-Feb-17 12:13pm    
5
Maciej Los 23-Feb-17 12:59pm    
Thank you, Karthik.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900