gridview 添加汇总行 footer
//----------------------------------------------------------------------------------
添加属性 showfooter=true
找到控件的 grdList_RowDataBound 事件
protected void grdList_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.Header)
{
}
if (e.Row.RowType == DataControlRowType.DataRow)
{
// 添加汇总行 20130923
//---------------------------------------------------------------------
count1 += Convert.ToInt32(DataBinder.Eval(e.Row.DataItem, "count1"));
count2 += Convert.ToInt32(DataBinder.Eval(e.Row.DataItem, "count2"));
count3 += Convert.ToInt32(DataBinder.Eval(e.Row.DataItem, "count3"));
//---------------------------------------------------------------------
if (CurrentUser.RegionDetailType != 1)
{
e.Row.Cells[0].Text = "";
}
}
// 添加汇总行 20130923
//---------------------------------------------------------------------
if (e.Row.RowType == DataControlRowType.Footer)
{
//e.Row.Cells[0].Text = "合计";
e.Row.Cells[1].Text = "合计";
e.Row.Cells[2].Text = count1.ToString();
e.Row.Cells[3].Text = count2.ToString();
e.Row.Cells[4].Text = count3.ToString();
e.Row.Font.Bold = true;
}
//---------------------------------------------------------------------
}