在gridview的RowCreated的事件里面写下如下代码
if (e.Row.RowType == DataControlRowType.Footer)
{
TableCellCollection tcc = e.Row.Cells;
//this.GridViewProjectGroupQuatityView.FooterRow.Cells.Add(new TableCell());
tcc.Clear();
e.Row.Cells.Add(new TableCell());
e.Row.Cells[0].Attributes.Add("colspan","4");
e.Row.Cells[0].Text = "平均值";
e.Row.Cells[0].HorizontalAlign = HorizontalAlign.Center;
e.Row.Cells.Add(new TableCell());
e.Row.Cells[1].BackColor = TransColor("#F2F2F0");
e.Row.Cells[1].Text = "";//
e.Row.Cells.Add(new TableCell());
e.Row.Cells[2].BackColor = TransColor("#F2F2F0");
e.Row.Cells[2].Text = "";//
e.Row.Cells.Add(new TableCell());
e.Row.Cells[3].BackColor = TransColor("#F2F2F0");
e.Row.Cells[3].Text = "";//
e.Row.Cells.Add(new TableCell());
e.Row.Cells[4].BackColor = TransColor("#F2F2F0");
e.Row.Cells[4].Text = "";//
e.Row.Cells.Add(new TableCell());
e.Row.Cells[5].BackColor = TransColor("#F2F2F0");
e.Row.Cells[5].Text = "";//
e.Row.Cells.Add(new TableCell());
e.Row.Cells[6].BackColor = TransColor("#F2F2F0");
e.Row.Cells[6].Text = "";//
e.Row.Cells.Add(new TableCell());
e.Row.Cells[7].BackColor = TransColor("#F2F2F0");
e.Row.Cells[7].Text = "";
e.Row.Cells.Add(new TableCell());
e.Row.Cells[8].BackColor = TransColor("#F2F2F0");
e.Row.Cells[8].Text = "";
e.Row.Cells.Add(new TableCell());
e.Row.Cells[9].BackColor = TransColor("#F2F2F0");
e.Row.Cells[9].Text = "";
e.Row.Cells.Add(new TableCell());
e.Row.Cells[10].BackColor = TransColor("#F2F2F0");
e.Row.Cells[10].Text = "";
e.Row.Cells.Add(new TableCell());
e.Row.Cells[11].BackColor = TransColor("#F2F2F0");
e.Row.Cells[11].Text = "";
e.Row.Cells.Add(new TableCell());
e.Row.Cells[12].BackColor = TransColor("#F2F2F0");
e.Row.Cells[12].Text = "</th></tr><tr>";//注意这里,要换行了哦!
e.Row.Cells.Add(new TableCell());
e.Row.Cells[13].Attributes.Add("colspan", "4");
e.Row.Cells[13].Text = "总值";
e.Row.Cells[13].HorizontalAlign = HorizontalAlign.Center;
e.Row.Cells.Add(new TableCell());
e.Row.Cells[14].BackColor = TransColor("#F2F2F0");
e.Row.Cells[14].Text = "";
e.Row.Cells.Add(new TableCell());
e.Row.Cells[15].BackColor = TransColor("#F2F2F0");
e.Row.Cells[15].Text = "";
e.Row.Cells.Add(new TableCell());
e.Row.Cells[16].BackColor = TransColor("#F2F2F0");
e.Row.Cells[16].Text = "";
e.Row.Cells.Add(new TableCell());
e.Row.Cells[17].BackColor = TransColor("#F2F2F0");
e.Row.Cells[17].Text = "";
e.Row.Cells.Add(new TableCell());
e.Row.Cells[18].BackColor = TransColor("#F2F2F0");
e.Row.Cells[18].Text = "";
e.Row.Cells.Add(new TableCell());
e.Row.Cells[19].BackColor = TransColor("#F2F2F0");
e.Row.Cells[19].Text = "";
e.Row.Cells.Add(new TableCell());
e.Row.Cells[20].BackColor = TransColor("#F2F2F0");
e.Row.Cells[20].Text = "";
e.Row.Cells.Add(new TableCell());
e.Row.Cells[21].BackColor = TransColor("#F2F2F0");
e.Row.Cells[21].Text = "";
e.Row.Cells.Add(new TableCell());
e.Row.Cells[22].BackColor = TransColor("#F2F2F0");
e.Row.Cells[22].Text = "";
e.Row.Cells.Add(new TableCell());
e.Row.Cells[23].BackColor = TransColor("#F2F2F0");
e.Row.Cells[23].Text = "";
e.Row.Cells.Add(new TableCell());
e.Row.Cells[24].BackColor = TransColor("#F2F2F0");
e.Row.Cells[24].Text = "";
e.Row.Cells.Add(new TableCell());
e.Row.Cells[25].BackColor = TransColor("#F2F2F0");
e.Row.Cells[25].Text = "";
}
效果如图