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. 帶固定標題和固定列的可滾動HTML表格
- 2. 滾動條和數據網格問題
- 3. 具有固定標題和滾動問題的Datagrid滾動條
- 4. 帶滾動頁面主體的固定表格標題
- 5. 如何製作帶有固定標題的可滾動表格
- 6. 滾動表格,保持標題固定
- 7. ng-table固定標頭和滾動條
- 8. 使用滾動條固定表格標題IE8中的GridView中
- 9. 具有固定標題,滾動條和動態高度的HTML表格
- 10. 滾動時固定標題
- 11. 固定標題和滾動HTML
- 12. 帶固定標題和滾動表體的表不會讓tbody滾動
- 13. 標題不滾動表固定標題
- 14. 表固定標題和滾動條第一列
- 15. 帶固定標題和動態高度的表格
- 16. 我想滾動固定的表格標題與表格主體數據?
- 17. 帶固定標題的HTML表格
- 18. 錨定慢速滾動固定標題
- 19. 燈箱加上固定燈箱(不帶滾動條滾動)
- 20. 需要帶有固定標題的可滾動戰斧表
- 21. 滾動固定標題下的頁面
- 22. 可滾動的固定格
- 23. Silverlight數據網格垂直滾動條中的問題
- 24. 問題:flex數據網格的水平滾動條
- 25. 固定滾動條位置
- 26. WebView Html固定標題滾動表
- 27. 視差滾動固定標題
- 28. 固定標題以上滾動表
- 29. 使用固定標題滾動UL
- 30. CSS固定標題,滾動正文
表達式(this.offsetParent.scrollTop); 在Firefox和Chrome上有問題 – 2010-02-03 15:31:16
在CodeProject站點給出的代碼在Firefox中都不適用於我。我仍在尋找答案。 – bgmCoder 2012-12-21 16:49:02