You must Sign In to post a response.

How to display Subtotals and totals in Asp.net Gridview

Hi frns

Pls let me know how to display Subtotals and totals In a Asp.net 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

Madhu


Comments

Author: Suthahar23 Sep 2007 Member Level: Gold   Points : 2

hai

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;

}

}


ok

by
suthahar.j
pullanviduthi
pudukkottai
jstech.4t@gmail.com


Sign In to post your comments