Forums » .NET » .NET »

How to display Subtotals and totals in Gridview

Posted Date: 22 Sep 2007      Posted By:: madhu kayam     Member Level: Bronze  Member Rank: 0     Points: 2   Responses: 1

Hi frns

Pls let me know how to display Subtotals and totals In a gridview..

For example consider..i have 3 coloums in gridivew...Account Number,Account and Income...

Based on Account i need to group the records and display the subtotoal for each Accout...and finnaly the Total.

Pls help me friends



#153295    Author: Suthahar      Member Level: Gold      Member Rank: 0     Date: 23/Sep/2007   Rating: 2 out of 52 out of 5     Points: 2


you use this code in grid databound evend

protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)


if (e.Row.RowType == DataControlRowType.DataRow)


GridView gv = e.Row.FindControl("gvReports") as GridView;

GridViewRow footerRow = gv.FooterRow;

foreach (GridViewRow row in gv.Rows)


Label labelTotal = footerRow.FindControl("lblTotal") as Label;

dayHour += Double.Parse((row.FindControl("lblHour") as Label).Text);

labelTotal.Text = dayHour.ToString();


totalHour += dayHour;

dayHour = 0.0;





Be Simple Be Sample

Post Reply     

 This thread is locked for new responses. Please post your comments and questions as a separate thread.
If required, refer to the URL of this page in your new post.

  • Return to Discussion Forum
  • Start new thread

  • Subscribe to Subscribers
    Active Members
    TodayLast 7 Daysmore...

    Awards & Gifts
    Talk to Webmaster Tony John
    Copyright © SpiderWorks Technologies Pvt Ltd., Kochi, India