gridview 多层表头 对齐的问题

feng8317 2010-04-09 11:10:58
protected void gdvInfo_RowCreated(object sender, GridViewRowEventArgs e)
{
switch (e.Row.RowType)
{
case DataControlRowType.Header:
//第一行
TableCellCollection tcHeader = e.Row.Cells;
tcHeader.Add(new TableHeaderCell());
tcHeader[0].Attributes.Add("rowspan", "3");
tcHeader[0].Attributes.Add("colspan", "1");
//tcHeader[0].Attributes.Add("bgcolor", "DarkSeaGreen");
tcHeader[0].Text = "";
tcHeader.Add(new TableHeaderCell());
tcHeader[1].Attributes.Add("rowspan", "2");
tcHeader[1].Attributes.Add("colspan", "5");
tcHeader[1].Text = "个人信息";

tcHeader.Add(new TableHeaderCell());
tcHeader[2].Attributes.Add("rowspan", "2");
tcHeader[2].Attributes.Add("colspan", "5");
tcHeader[2].Text = "部门信息";

tcHeader.Add(new TableHeaderCell());
tcHeader[3].Attributes.Add("rowspan", "2");
tcHeader[3].Attributes.Add("colspan", "1");
tcHeader[3].Text = "";

tcHeader.Add(new TableHeaderCell());
tcHeader[4].Attributes.Add("rowspan", "1");
tcHeader[4].Attributes.Add("colspan", "4");
tcHeader[4].Text = "权限信息</th></tr><tr>";

tcHeader.Add(new TableHeaderCell());
tcHeader[5].Attributes.Add("rowspan", "1");
tcHeader[5].Attributes.Add("colspan", "4");
tcHeader[5].Text = "业务信息</th></tr><tr>";
break;
}
}

我总共有三行,我在RowCreated里面创建了两行表头,第三行表头,我在asp.net里定义的,为什么我显示出来后,数据绑定是正确的,但是前面五个列的表头没有显示,值显示后面几列的表头。我在这里不定义,就能全部显示。
...全文
61 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
yingyuebingya 2010-04-09
  • 打赏
  • 举报
回复

TableCell cel = new TableCell();
celAttributes.Add("rowspan", "3");
celAttributes.Add("colspan", "1");
celText = "";
tcHeader.Add(cel);
//这样可以吗?
June1991 2010-04-09
  • 打赏
  • 举报
回复
学习学习。。
TiramisuH 2010-04-09
  • 打赏
  • 举报
回复
</th></tr><tr> 是不是应该是</th><th>就好了

110,538

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧