多行表头合并, 网上很多实例, 这里写的很详细, 力求让每个人都能看懂.
实现原理:GridView在ASP.NET中最终转为HMTL的表格显示表头。
在GridView创建行表头行时: e.Row.RowType == DatacontrolRowType.Header
清除掉旧的表头, 再重新拼接新的表头.
TableHeaderCell thc = new TableHeaderCell();
thc.Text = "表头";
对应生成的HTML为:<th>表头</th>
多行表头合并效果图
| 测试多行合并表头 | ||||||
|---|---|---|---|---|---|---|
| 表头 | 表头1 | 表头2 | 表头3 | |||
| 表头1-1 | 表头2-1 | 表头2-2 | 表头3-1 | 表头3-2 | 表头3-3 | |
1
protected void GridView1_RowCreated(object sender, GridViewRowEventArgs e)
2
}
2