i have to add the total no of present in grid view using asp.net
eg
id name status
1 s Present
1 s Present
1 s Present
total 3
i need to show the present days as total
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 attend5days leftRegister
Abhishek KumarRank #510 · 4.8K reputationPosted May 16, 2014, 4:06 AM EDT
you can try below code
Its not full code but a it will solve your problem.
RowDataBound event of grid put the below code and you can display total presents in footer.
if (e.Row.RowType == DataControlRowType.DataRow)
{
Label Attendance = (Label)e.Row.FindControl("lblAttdence");
decimal Presents = Convert.ToDecimal(Attendance.tostring());
total += Presents;
}
if (e.Row.RowType == DataControlRowType.Footer)
{
Label lblTotalAttendance = (Label)e.Row.FindControl("lblTotal");
lblTotal.Text = total.ToString();
}
Hope this will help.
Thanks.