多行表头

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 = "超标量";

        }

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值