int sum2 = 0;
for (int i = 0; i < this.GridView1.Rows.Count; i++)
{
GridViewRow row = this.GridView1.Rows[i];
if (row.Cells[2].Text.ToString() != " ") //数据库里null值
{
sum2 += Convert.ToInt32(row.Cells[2].Text.ToString());
}
} //汇总
if (e.Row.RowType == DataControlRowType.Footer)
{
e.Row.Cells[1].Text = "总计";
e.Row.Cells[2].Text = sum2.ToString();
}
我用的gridview做的。具体参考你可以网上搜索 gridview72变。
温馨提示:答案为网友推荐,仅供参考