样式:
1
.FixGridHeaderAbove
2
{
3
text-align: center;
4
font-weight:bold;
5
background-color:#C0C0FF;
6
POSITION: relative;
7
TOP: expression(this.offsetParent.scrollTop) ;
8
}
.FixGridHeaderAbove2
{3
text-align: center;4
font-weight:bold;5
background-color:#C0C0FF;6
POSITION: relative; 7
TOP: expression(this.offsetParent.scrollTop) ;8
}
代码:
1
<
div
style
="OVERFLOW: auto; HEIGHT: 380px; WIDTH: 500;"
align
="center"
>
2
<
asp:DataGrid
id
="DataGrid1"
runat
="server"
>
3
<
HeaderStyle
CssClass
="FixGridHeaderAbove"
></
HeaderStyle
>
4
</
asp:DataGrid
>
5
</
div
>
<
div
style
="OVERFLOW: auto; HEIGHT: 380px; WIDTH: 500;"
align
="center"
>
2
<
asp:DataGrid
id
="DataGrid1"
runat
="server"
>
3
<
HeaderStyle
CssClass
="FixGridHeaderAbove"
></
HeaderStyle
>
4
</
asp:DataGrid
>
5
</
div
>
本文介绍了一种在滚动时保持DataGrid标题可见的方法,通过使用特定的CSS样式和ASP.NET DataGrid组件属性实现。该技巧适用于需要在大量数据中保持列标题清晰可见的场景。

}
112

被折叠的 条评论
为什么被折叠?



