How to calculate sum of total in grid and display in label
2 Answers
Know the answer? Post it. Somebody with the same question will find it here.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend4days leftRegister
Pankaj Kumar ChoudharyRank #80 · 24.4K reputationPosted Mar 7, 2015, 6:23 AM EST
For better understanding your query
Fathima Jabbar15 reputationPosted Mar 31, 2015, 3:48 AM EDT
Hope the below given code snippet might help you
protected void Gridview1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
if (DataBinder.Eval(e.Row.DataItem, "COLUMNNAME") != DBNull.Value)
{
var_sum = Convert.ToInt32(DataBinder.Eval(e.Row.DataItem, "COLUMNNAME"));
}
}
if (e.Row.RowType == DataControlRowType.Footer)
{
e.Row.Cells[2].Text = var_sum;
}
}