前台:设置gridview的ShowFooter="True" ,否则默认表头为
隐藏
的!
后台代码
RowDataBound事件
private double sum = 0; protected void GetAccountsOpened10_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowIndex >= 0) { sum += Convert.ToDouble(e.Row.Cells[1].Text); } else if (e.Row.RowType == DataControlRowType .Footer) { e.Row.Cells[1].Text = "total:" +sum.ToString(); } }