Last post Dec 03, 2009 10:26 PM by chetan.sarode
Nov 28, 2009 05:28 AM|Qweeg|LINK
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.Text);
else if (e.Row.RowType == DataControlRowType.Footer)
e.Row.Cells.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 =
But I don't know what to cast to to replicate this in the starter kit. Any tips would be much appreciated.
Dec 03, 2009 10:26 PM|chetan.sarode|LINK
You need to use gridView.FindControl("controlName"); to get the control in the row.
You can also get at the DataItem property of the Row in question and cast it to the appropriate type and extract the information directly