C#表头固定

<%@ Control Language="C#" AutoEventWireup="true" CodeFile="info.ascx.cs" Inherits="DotNetNuke.Modules.HRAddUser.info" %>
<style>
    .tablestyles {
        position: absolute;
        margin-top: -40px;
    }

    .tablestyles th {
        z-index: 1999;
    }

    .tablestylesgv {
        margin-top: 40px;
    }
</style>
<asp:Panel ID="Panel1" runat="server">
    <table>
     
     
        <tr>
            <td>
                 <div style="overflow-y: scroll; height: 600px; ">
         <asp:GridView ID="gridinfo" runat="server" AutoGenerateColumns="False" EmptyDataText="当前没有数据."
                    BackColor="White" BorderColor="#999999" BorderStyle="None" BorderWidth="1px"
                    CellPadding="3" CssClass="GridFont tablestylesgv" GridLines="Vertical" Font-Size="Small" ShowFooter="True" 
                    OnRowCreated="gridStatistic_RowCreated" >
                    <PagerSettings Mode="NumericFirstLast" />
                    <FooterStyle BackColor="#CCCCCC" ForeColor="Black" />
                    <Columns>
                  ......
                    </Columns>
                    <RowStyle BackColor="#EEEEEE" ForeColor="Black" />
                    <SelectedRowStyle BackColor="#008A8C" Font-Bold="True" ForeColor="White" />
                    <PagerStyle BackColor="#999999" ForeColor="Black" HorizontalAlign="Center" />
                    <HeaderStyle BackColor="#C0C0FF" Font-Bold="True" ForeColor="White" CssClass="tablestyles"/>
                    <AlternatingRowStyle BackColor="Gainsboro" />
                </asp:GridView>
        </div>
            </td>
        </tr>
    </table>

    <script type="text/javascript">
        window.onload = function () {
             var wi = [50,120,320,130, 130, 130, 130, 130, 130, 130, 130, 130, 131.1];
            for (var i = 0; i < 13; i++) {
             document.getElementById("gridinfoId").rows[0].cells[i].style.width = wi[i] + "px"; 
           }
        }
    </script>
</asp:Panel>

  

posted @ 2021-09-05 20:08  刘贵庆  阅读(160)  评论(0编辑  收藏  举报