Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
Dear Friends,
 
Have a Good Day !!
 
How to do Total sum in Gridview Footer in Asp.net C# ?
=======================================
 
I have a Gridview which has the fields like UserName, Login Time , Logout Time , Duration. I need to do total duration of hours in footer
 
UserName | Login Time | Logout Time | Duration
 

These are my Fields in my Gridview
 
So, Please help me how to do Total Duration Calculations in Gridview Footer .
 
thanks in Advance.
Posted 26-Aug-12 20:11pm
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

var result = from p in st.prices select new {
            p.id,
              p.Name,
               p.price1 };
            GridView1.DataSource = result;
            GridView1.DataBind();
            double sum=0;
            foreach(var item in result){
 
                sum += Convert.ToDouble(item.price1);
            }
            Label lblsum = (Label)GridView1.FooterRow.FindControl("Lbltotal");
            lblsum.Text = sum.ToString();
  Permalink  
v2
Comments
karthik mahalingam01 at 30-Dec-13 3:55am
   
good try..
karthik mahalingam01 at 30-Dec-13 3:57am
   
always put your code in code block...
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

  Permalink  
Comments
__TR__ at 27-Aug-12 2:25am
   
My 5!
karthik mahalingam01 at 30-Dec-13 3:57am
   
nice links.
Mohamed Mitwalli at 27-Aug-12 2:28am
   
Thank you TR :)
Mohamed Mitwalli at 30-Dec-13 4:22am
   
Thanks Karthik :)
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

 
decimal a = 0;
            Int32 y = GridView1.Items.Count;
            for (Int32 i = 0; i < y ; i++)
            {
 
                a = a + Convert.ToDecimal(((Label)GridView1.Items[i].FindControl("lbl_subtoprice")).Text.ToString());
 
            }
 
            lbl_grandtotal.Text = Convert.ToString(a);
lbl_subtopricel id of your durations values
and
lbl_grandtotal is id of label in footer
  Permalink  
Comments
karthik mahalingam01 at 30-Dec-13 3:56am
   
good try.
Omprakash Kukana at 30-Dec-13 3:57am
   
thanx
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 4

  Permalink  
v2

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

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 886
1 OriginalGriff 390
2 CPallini 255
3 Volynsky Alex 205
4 Richard Deeming 175
0 OriginalGriff 5,540
1 Sergey Alexandrovich Kryukov 4,668
2 CPallini 4,540
3 George Jonsson 3,102
4 Gihan Liyanage 2,445


Advertise | Privacy | Mobile
Web03 | 2.8.140916.1 | Last Updated 30 Dec 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100