![](https://www.cnblogs.com/Images/OutliningIndicators/ContractedBlock.gif)
Code
decimal totalstock = 0;
protected void GridView2_DataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
totalstock += Convert.ToDecimal(DataBinder.Eval(e.Row.DataItem, "total"));
// totalstock += DataBinder.Eval(e.Row.DataItem, "total");
//在这里就可以实现总和的计算了
}
else if (e.Row.RowType == DataControlRowType.Footer)
{
e.Row.Cells[2].Text = "合计:";
e.Row.Cells[2].HorizontalAlign = HorizontalAlign.Right;
e.Row.Cells[3].Text = totalstock.ToString();
}
}
posted on
2009-04-01 19:19
微星
阅读(
378)
评论()
编辑
收藏
举报