Gridview Footer calculator
Revision 3
Hi guys
Trying to create a footer calculator. Problem is now the if() statemets are skiped. any ideas Y this hapens? Check the code below:
protected void grvTravelClaims_RowDataBound(object sender, GridViewRowEventArgs e)
{
decimal _total = 0.0M;
int totalItems = 0;
if (e.Row.RowType == DataControlRowType.DataRow)
{
Label lblKillometers = (Label)e.Row.FindControl("lblKillometers");
decimal killometers = Decimal.Parse(lblKillometers.Text);
_total += killometers;
totalItems += 1;
}
if (e.Row.RowType == DataControlRowType.Footer)
{
Label lblTotalKillometers = (Label)e.Row.FindControl("lblTotalKillometers");
lblTotalKillometers.Text = _total.ToString();
}
}
Posted 10-Mar-12 2:49am
by
Anele Ngqandu.