Monday, August 24, 2009

How to Display Sum of each column in the Footer of a GridView Control

Put OnRowDataBound event in Gridview tag
from design page , it will show how to display sum of each column in the footer of the GridView control

protected void gvAssets_RowDataBound(object sender, GridViewRowEventArgs e)
if (e.Row.RowType == DataControlRowType.DataRow)
decimal rowbal = Convert.ToDecimal(DataBinder.Eval(
e.Row.DataItem, "CurrentBalance"));
balance = balance + rowbal;
if (e.Row.RowType == DataControlRowType.Footer)
Label lblbalFooter = (Label)e.Row.FindControl("lblbalFooter");
lblbalFooter.Text = Convert.ToString(String.Format("{0:0,0.00}",

1 comment: