protected void GridView1_RowCreated(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.Header)
{
TableCellCollection tcl = e.Row.Cells;
//清除自动生成的表头
tcl.Clear();
//添加新的表头第一行
tcl.Add(new TableHeaderCell());
tcl[0].RowSpan = 3;
tcl[0].Text = "污染物名称";
tcl.Add(new TableHeaderCell());
tcl[1].RowSpan = 3;
tcl[1].Text = "产生量(吨)";
tcl.Add(new TableHeaderCell());
tcl[2].ColumnSpan = 4;
tcl[2].Text = "去除量(吨)";
tcl.Add(new TableHeaderCell());
tcl[3].ColumnSpan = 9;
tcl[3].Text = "排放量(吨)";
tcl.Add(new TableHeaderCell());
tcl[4].RowSpan = 3;
tcl[4].Text = "污染物排放标准值</th></tr><tr>";
//这里的</th></tr>表示是第一行结束,<tr>表示第二行开始,感觉就和table的表格合并一样
//第二行表头
tcl.Add(new TableHeaderCell());
tcl[5].RowSpan = 2;
tcl[5].Text = "合计";
tcl.Add(new TableHeaderCell());
tcl[6].RowSpan = 2;
tcl[6].Text = "其中新增设施";
tcl.Add(new TableHeaderCell());
tcl[7].RowSpan = 2;
tcl[7].Text = "其中燃烧废气";
tcl.Add(new TableHeaderCell());
tcl[8].RowSpan = 2;
tcl[8].Text = "其中工艺废气";
tcl.Add(new TableHeaderCell());
tcl[9].ColumnSpan = 3;
tcl[9].Text = "排放合计";
tcl.Add(new TableHeaderCell());
tcl[10].ColumnSpan = 3;
tcl[10].Text = "其中燃烧废气排放量";
tcl.Add(new TableHeaderCell());
tcl[11].ColumnSpan = 3;
tcl[11].Text = "其中工艺废气排放量</th></tr><tr>";
//第三行表头 同上面所说的
tcl.Add(new TableHeaderCell());
tcl[12].Text = "合计";
tcl.Add(new TableHeaderCell());
tcl[13].Text = "达标量";
tcl.Add(new TableHeaderCell());
tcl[14].Text = "超标量";
tcl.Add(new TableHeaderCell());
tcl[15].Text = "合计";
tcl.Add(new TableHeaderCell());
tcl[16].Text = "达标量";
tcl.Add(new TableHeaderCell());
tcl[17].Text = "超标量";
tcl.Add(new TableHeaderCell());
tcl[18].Text = "合计";
tcl.Add(new TableHeaderCell());
tcl[19].Text = "达标量";
tcl.Add(new TableHeaderCell());
tcl[20].Text = "超标量";
}
多行表头
最新推荐文章于 2023-10-30 17:34:09 发布