固定gridview表头

jojohappy99 2009-10-07 11:39:39
怎样固定gridview的表头呢。。。
确实有很多方法解决了。。。但是都不能左右拖。。。
有没什么办法上下拖表头不动。。。左右拖表头跟着左右走呢?
...全文
108 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
wuyq11 2009-10-07
  • 打赏
  • 举报
回复
.Freezing
{
position:relative ;
table-layout:fixed;
top:expression(this.offsetParent.scrollTop);
z-index: 10;
}
<div style="overflow-y: scroll; height: 200px;width:200px" >
<asp:GridView ID="GridView1" runat="server" OnRowCreated="GridView1_RowCreated" OnRowDataBound="GridView1_RowDataBound">
<HeaderStyle CssClass="Freezing" />
</asp:GridView>
</div>
protected void GridView1_RowCreated(object sender, GridViewRowEventArgs e)
{
switch(e.Row.RowType)
{

}
}

http://topic.csdn.net/u/20090324/11/8451f630-adc5-44ba-a6fd-a55645773663.html
http://topic.csdn.net/u/20090108/15/aec335c6-2731-4d92-9a30-51a5ab681567.html
myshuo 2009-10-07
  • 打赏
  • 举报
回复
上面的代码我试过,效果还可以,不过上下拖动数据时,表头会消失。
happy664618843 2009-10-07
  • 打赏
  • 举报
回复
Css可以解决

.Freezing {position:relative;table-layout:fixed;top:expression(this.offsetParent.scrollTop);z-index: 10;}
.Freezing th{text-overflow:ellipsis;overflow:hidden;white-space: nowrap;padding:2px;}



<HeaderStyle BackColor="#006699" Font-Bold="True" ForeColor="White" CssClass="Freezing" />
jojohappy99 2009-10-07
  • 打赏
  • 举报
回复
解决不了阿。。。。都是横向拖动的时候表头也不动。。。

62,046

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

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