先设置showfooter属性为true  再写一下代码

 

private double sum = 0;
private int sum1 = 0;
protected void GridView1_DataRowBinding(object sender, GridViewRowEventArgs e)
{

if (e.Row.RowIndex > -1)
{
sum += Convert.ToDouble(e.Row.Cells[1].Text);
sum1 += Convert.ToInt32(e.Row.Cells[2].Text);
}
// 合计
if (e.Row.RowType == DataControlRowType.Footer)
{
e.Row.Cells[0].Text = "总计" + GridView1.Rows.Count.ToString() + "条数据";
e.Row.Cells[1].Text = "总计发货金额:" + sum.ToString();
e.Row.Cells[2].Text ="总计发货数量:"+ sum1.ToString();

}
}

posted on 2016-01-18 10:55  我的逗比会发光。  阅读(471)  评论(0编辑  收藏  举报