标签:
1、在WebForm窗体中,设置GridView的ShowFooter="True"
2、在后台代码中
private int jhrs=0,ybrs=0;//定义变量
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowIndex >= 0)
{
jhrs += Convert.ToInt16(e.Row.Cells[4].Text);
ybrs += Convert.ToInt16(e.Row.Cells[5].Text);
}
else if (e.Row.RowType == DataControlRowType.Footer)
{
e.Row.Cells[0].Text = "合计";
e.Row.Cells[4].Text = jhrs.ToString();
e.Row.Cells[5].Text = ybrs.ToString();
}
}
标签:
原文地址:http://www.cnblogs.com/xusy/p/4832448.html