protected void gviewEmployees_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=\"\"");
e.Row.Attributes.Add("onmouseover", "this.style.backgroundColor=\"#BFDFFF\"");
TextBox txt = (TextBox)e.Row.Cells[3].FindControl("txtOrderNum");
SumConsume += Convert.ToSingle(e.Row.Cells[2].Text.ToString().Substring(1)) * Convert.ToSingle(txt.Text);
}
IF (e.Row.RowType == DataControlRowType.Footer)
{
e.Row.Cells [. 4] .Text = "Your total consumption:" + string.Format ( "{0 : C}", Convert.ToDecimal (SumConsume.ToString ()));
}
}
Reproduced in: https: //www.cnblogs.com/zhangchenliang/archive/2008/01/08/1029669.html