Displaying Summary Data in the Footer
-
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnaspp/html/GridViewEx03.asp[^] The article link is abit wrong. The link is on GridView Examples for ASP.NET 2.0: Displaying Summary Data in the Footer. I am using .NET 2.0 C# and had learn from that article to display summary data in the footer.
protected void GridView4_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { absentTotal += Convert.ToInt32(DataBinder.Eval(e.Row.DataItem, "Category")); } else if (e.Row.RowType == DataControlRowType.Footer) { e.Row.Cells[0].Text = "Total Absent:"; e.Row.Cells[3].Text = absentTotal.ToString("c"); e.Row.Font.Bold = true; } }
I then forgetten that my data values for Category is a string values "A", "P" etc. How can I achieved similar way of calculating the row for Category meaning calculating how many A's and P's. Perhaps the footer of the gridview would show: Total Absent (A): 5 Total Present (P): 10thanks in advance. Much appreciated.