我有一个网格视图,我想要一个没有溢出=滚动样式的固定标题。也就是说,当它们是更多记录时,默认情况下网格视图会滚动。现在我如何显示固定标题。
这是我的网格视图。
<asp:GridView ID="gvStd" runat="server" DataKeyNames ="ID" AutoGenerateColumns="False" OnRowDataBound="gvStd_RowDataBound"
CssClass="table" EnableViewState="False" EmptyDataText="Such Not Found!"
CellPadding="4" ForeColor="#333333" GridLines="None" OnRowCommand ="gvStd_RowCommand" BorderStyle="None" >
<RowStyle BackColor="#FFFBD6" ForeColor="#333333" CssClass="HeaderFreez"/>
<Columns>
<asp:TemplateField HeaderText="School Code" >
<ItemTemplate>
<asp:Label ID="lblSchoolCode" runat="server"
Text='<%# Bind("SCHOOL_CODE")%>' />
<asp:TextBox ID="ID_TO_Update_All"
runat="server" Text='<%# Bind("ID")%>' Visible="false" />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Class">
<ItemTemplate>
<asp:Label ID="lblClass" runat="server" Text='<%#
Bind("CLASS") %>' Visible="true"/>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Sec">
<ItemTemplate>
<asp:Label ID="lblSection" runat="server" Text='<%#
Bind("SECTION") %>' Visible="true"/>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<FooterStyle BackColor="#990000" Font-Bold="True"
ForeColor="White" />
<PagerStyle BackColor="#FFCC66" ForeColor="#333333"
HorizontalAlign="Center" />
<SelectedRowStyle BackColor="#FFCC66" Font-Bold="True"
ForeColor="Navy" />
<HeaderStyle BackColor="#00ba8b" Font-Bold="True"
ForeColor="White" />
<AlternatingRowStyle BackColor="White" />
</asp:GridView>
<style>
th {
background: cornflowerblue!important;
color:white!important;
position: sticky!important;
top: 0;
box-shadow: 0 2px 2px -1px rgba(0, 0, 0, 0.4);
}
th, td {
padding: 0.25rem;
}
</style>
- 只需在 Web 表单的 Head 标签中添加此样式即可。
- 直接添加母版页标题以将其应用到所有子页面。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)