0
A
回答
0
有这个CodeProject上的条目:Fixed Header in ASP.NET DataGrid
1
我工作过一段时间,在这并放弃了让所有的浏览器的CSS工作。尽管不是一个简单的方法来实现这一点,但只需要有两个不同的表格,其列宽匹配。第一个表包含标题,第二个表包含内容并且可滚动。
我用jQuery使所有的列宽匹配。
对于一个完整的说明,请参见此篇:Scrollable DataGrid table with Fixed Header with jQuery
0
为了解决这个问题,我放置在原始上方的第二数据网格,我的尺寸的所有列在两个数据网格相等。在显示数据的数据网格中,我将标题设置为不显示。在后面的代码中,我将顶级数据网格绑定到空数据表,并设置绑定字段以在空时显示标题。
<div style="padding-bottom:2px">
<asp:GridView id="RoleListHeader" runat="server" AutoGenerateColumns="false" showheaderwhenempty="True" showheader="true" height="20px" width="350px" selectedrowstyle-height="20px" rowstyle-height="20px" headerstyle-height="10px" forecolor="#ff333333" backcolor="White">
\t <columns>
\t \t <asp:TemplateField ItemStyle-Width="23">
<ItemTemplate>
\t <asp:CheckBox></asp:CheckBox>
\t \t \t \t \t </ItemTemplate>
</asp:TemplateField>
\t \t <asp:BoundField DataField="SystemDesc" HeaderText="Role Description" ReadOnly="true" ItemStyle-Width="174"></asp:BoundField>
\t \t <asp:BoundField DataField="EndDate" HeaderText="EndDate" ReadOnly="true" ItemStyle-Width="153"></asp:BoundField>
\t </columns>
</asp:GridView>
</div>
<div style="max-height:300px;overflow:auto">
<asp:GridView id="RoleList" runat="server" AutoGenerateColumns="false" showheaderwhenempty="True" showheader="false" height="0px" width="350px" selectedrowstyle-height="20px" rowstyle-height="20px" headerstyle-height="10px" forecolor="#ff333333" backcolor="White" rowstyle-horizontalalign="Center" rowstyle-borderstyle="Solid" rowstyle-bordercolor="#ff404040">
\t <columns>
\t \t <asp:TemplateField ItemStyle-Width="23">
<ItemTemplate>
\t <asp:CheckBox runat="server" OnCheckedChanged="GVChkBox_CheckChanged" AutoPostBack="true"></asp:CheckBox>
\t </ItemTemplate>
</asp:TemplateField>
\t \t <asp:BoundField DataField="SystemDesc" HeaderText="Role Description" ReadOnly="true" ItemStyle-Width="174"></asp:BoundField>
\t \t <asp:BoundField DataField="EndDate" HeaderText="EndDate" ReadOnly="true" ItemStyle-Width="153"></asp:BoundField>
\t \t <asp:BoundField DataField="ADHSystemId" ShowHeader="false"></asp:BoundField>
\t </columns>
</asp:GridView>
</div>
相关问题
- 1. 带有垂直滚动条和固定标题的web2py网格
- 2. 滚动条和数据网格问题
- 3. 具有固定标题和滚动问题的Datagrid滚动条
- 4. 带有可滚动行和固定标题的表格
- 5. 滚动带内容的固定标题
- 6. 固定标题和固定右滚动条
- 7. 标题固定在滚动条上
- 8. 固定标题与垂直滚动条
- 9. 带固定标题的可滚动调整大小的表格
- 10. 如何制作带有固定标题的可滚动表格
- 11. 带有固定标题的可滚动表格
- 12. 带滚动页面主体的固定表格标题
- 13. 如何在带有固定标题的表格中添加滚动条?
- 14. 滚动表格,保持标题固定
- 15. 带固定标题和固定列的HTML数据表
- 16. ng-table固定标头和滚动条
- 17. 使用滚动条固定表格标题IE8中的GridView中
- 18. 带滚动条的固定盒?
- 19. 具有固定标题,滚动条和动态高度的HTML表格
- 20. 滚动时固定标题
- 21. 固定标题和滚动HTML
- 22. 滚动时在固定标题和导航条下的内容
- 23. 带固定标题和滚动表体的表不会让tbody滚动
- 24. 标题不滚动表固定标题
- 25. 表固定标题和滚动条第一列
- 26. 带有固定第一列的表格滚动条
- 27. 带固定标题和动态高度的表格
- 28. 带有固定标题和固定第一列的动态HTML表格
- 29. 滚动定位时的固定标题
- 30. 带固定标题的HTML表格
表达式(this.offsetParent.scrollTop); 在Firefox和Chrome上有问题 – 2010-02-03 15:31:16
在CodeProject站点给出的代码在Firefox中都不适用于我。我仍在寻找答案。 – bgmCoder 2012-12-21 16:49:02