Monday, February 17, 2014

Display Sum Total in the Footer of the GridView Control

private decimal sum = 0;

protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
sum = sum + Convert.ToDecimal(e.Row.Cells[2].Text);
}
else if (e.Row.RowType == DataControlRowType.Footer)
{
e.Row.Cells[1].Text = “Total Rs”;
//e.Row.Cells[2].Text = sum.ToString(“c”, new CultureInfo(“hi-IN”));
e.Row.Cells[2].Text = sum.ToString();
e.Row.Font.Bold = true;
}

}

No comments:

Post a Comment

Generate All Database Backup From Sql Server Using Query

DECLARE   @name   VARCHAR ( 50 )   -- database name DECLARE   @path   VARCHAR ( 256 )   -- path for backup files DECLARE   @fileName  ...