ShowFooter="True"
<FooterStyle BackColor="#cccccc" />
private double sum = 0;
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowIndex >= 0)
{
sum += Convert.ToDouble(e.Row.Cells[3].Text);
}
else if (e.Row.RowType == DataControlRowType.Footer)
{
e.Row.Cells[2].Text = "总:";
e.Row.Cells[3].Text = sum.ToString();
e.Row.Cells[0].Text = "平均:";
e.Row.Cells[1].Text = ((int)(sum / GridView1.Rows.Count)).ToString();
}
}
演示 下载