您的位置:首页 > 其它

GridView添加统计(合计)行

2009-04-01 19:19 260 查看
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();

}

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: