Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/35.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
ASP.NET Gridview的固定列标题_Asp.net_Css_Gridview_Scroll_Panel - Fatal编程技术网

ASP.NET Gridview的固定列标题

ASP.NET Gridview的固定列标题,asp.net,css,gridview,scroll,panel,Asp.net,Css,Gridview,Scroll,Panel,我有一个ASP.NET面板,里面有一个gridview。下面是它的标记: <asp:Panel runat="server" ID="searchResultsPanel" CssClass="datagrid" ClientIDMode="Static" style="display:none; max-height:500px; max-width:700px; overflow:auto;" > <asp:GridView runat="server" ID="g

我有一个ASP.NET面板,里面有一个gridview。下面是它的标记:

<asp:Panel runat="server" ID="searchResultsPanel" CssClass="datagrid" ClientIDMode="Static" style="display:none; max-height:500px; max-width:700px; overflow:auto;" >
    <asp:GridView runat="server" ID="gridMemberInfo" AutoGenerateColumns="false" EmptyDataText="No Members Were Found." OnRowCommand="Command_SearchGrid" ShowHeader="true" ShowHeaderWhenEmpty="true" >
        <PagerSettings Visible="false" />
        <AlternatingRowStyle CssClass="alt" />
        <Columns>
            <asp:ButtonField ButtonType="Link" Text="Select" CommandName="SelectRow" />
            <asp:BoundField  HeaderText="PMI"                DataField="PMI" />
            <asp:BoundField  HeaderText="Product"            DataField="Product" ItemStyle-Width="110px"  />
            <asp:BoundField  HeaderText="County"             DataField="County" />
            <asp:BoundField  HeaderText="Last Name"          DataField="LastName" />
            <asp:BoundField  HeaderText="First Name"         DataField="FirstName" />
            <asp:BoundField  HeaderText="Currently Enrolled" DataField="CurrentlyEnrolled" ItemStyle-Width="50px" />
        </Columns>
    </asp:GridView>
</asp:Panel>
为了让gridview使用AD元素进行渲染,我在代码隐藏中这样做:
this.gridMemberInfo.HeaderRow.TableSection=TableRowSection.TableHeader


因为我将面板的溢出设置为自动,所以当gridview有很多行时,我可以滚动。我现在想做的是使标题行固定,以便在滚动时始终可以看到它。我试过设置
位置:固定.datagrid表中的code>和
CSS类,但这不起作用。我尝试了其他几种选择,但没有成功。有人能帮我解决这个问题吗

你不能在IE上这样做,因为thead不被认为是css解释器。您需要实现一个wapping div来保存您的头。或者使用以前使用过的:

或者你可以看看:

取自堆栈回答:

.datagrid table 
{ 
    border-collapse: collapse; 
    text-align: left; 
    width: 100%; 
} 

.datagrid 
{
    font: normal 12px/150% Arial, Helvetica, sans-serif; 
    background: #fff; 
    overflow: hidden; 
    border: 2px solid #006699; 
    -webkit-border-radius: 10px; 
    -moz-border-radius: 10px; 
    border-radius: 10px; 
}

.datagrid table td, .datagrid table th 
{ 
    padding: 3px 10px; 
}

.datagrid table thead th 
{
    background:-webkit-gradient( linear, left top, left bottom, color-stop(0.05, #00A2F2), color-stop(1, #002C42) );
    background:-moz-linear-gradient( center top, #00A2F2 5%, #002C42 100% );
    filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#00A2F2', endColorstr='#002C42');
    background-color:#00A2F2; 
    color:#FFFFFF; 
    font-size: 12px; 
    font-weight: bold; 
    border: none;
} 

.datagrid table thead th:first-child 
{ 
    border: 3px; 
}

.datagrid table tbody td
{ 
    color: #00496B; 
    font-size: 12px;
    font-weight: normal; 
}

.datagrid table tbody .alt td 
{ 
    background: #E1EEF4; 
    color: #00496B; 
}

.datagrid table tbody td:first-child 
{ 
    border-left: none; 
}

.datagrid table tbody tr:last-child td 
{ 
    border-bottom: none; 
}