我的HTML代码中的div中有一个GridView,如下所示:
<div class="container" style="width: 80%; height: 800px; overflow: scroll">
<asp:GridView ID="GridView1" runat="server" AllowPaging="True" PageSize="40" AllowSorting="True"
AutoGenerateSelectButton="True" EnableModelValidation="False" OnPageIndexChanging="GridView1_SelectedIndexChanged"
AutoGenerateColumns="false" OnSorting="GridView1_Sorting" CssClass="mydatagrid"
PagerStyle-CssClass="pager" HeaderStyle-CssClass="headerGrida1" RowStyle-CssClass="rows"
ShowHeaderWhenEmpty="true" Font-Size="X-Small" ForeColor="Black">
div使它已经可滚动但我还需要一个固定的网格标题。我用CSS尝试的东西没有用......
我试过容器:
.container
{
overflow: scroll;
}
.container table th
{
position: relative;
}
.container table tbody
{
overflow: hidden;
}
</style>
这与Gird:
.headerGrida1
{
background-color: #4a708b;
font-family: Calibri;
color: White;
border: none 0px transparent;
height: 25px;
text-align: center;
font-size: 16px;
position: relative;
}
但似乎没有任何作用......
答案 0 :(得分:1)
以下是使用垂直和水平滚动条修复标题的好方法
http://www.dotnetbull.com/2011/11/scrollable-gridview-with-fixed-headers.html
答案 1 :(得分:0)