I have added totals to the footer of the ProjectList gridview by using the RowDataBound event in this kind of way:
protected void ProjectListGridView_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
_MonTotalHours += Convert.ToDecimal(e.Row.Cells[3].Text);
}
else if (e.Row.RowType == DataControlRowType.Footer)
{
e.Row.Cells[3].Text = _MonTotalHours.ToString();
}
}
This works, but it seems like referencing the cells by index is a bit of a pain - if I add columns I have to remember to change the index. I found a similar example on MSDN where the the row is cast into something more useful like this:
// Reference the ProductsRow via the e.Row.DataItem property
Northwind.ProductsRow product =
(Northwind.ProductsRow)
((System.Data.DataRowView)e.Row.DataItem).Row;
But I don't know what to cast to to replicate this in the starter kit. Any tips would be much appreciated.
Thanks,
Tim