ASP.NET中的网格视图静态头 [英] Grid view static header in asp.net

查看:42
本文介绍了ASP.NET中的网格视图静态头的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个网格视图,我想要一个没有header = scroll样式的固定标题.那是当它们是更多记录时,默认情况下网格视图滚动.现在我如何显示固定的标题.

I have a grid view i want a fixed header without style of overflow=scroll. that is when their is a more records the grid view scroll by default.now how i can show fixed header.

这是我的网格视图.

          <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>

  1. 只需将此样式添加到您的Webform的Head Tag中即可.
  2. 直接添加您的母版页眉,以将其应用于所有子页面.

这篇关于ASP.NET中的网格视图静态头的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆