程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> .NET網頁編程 >> ASP.NET >> ASP.NET基礎 >> ASP.NET 固定標題列與欄位的具體實現

ASP.NET 固定標題列與欄位的具體實現

編輯:ASP.NET基礎

APSX 頁面代碼: JS
復制代碼 代碼如下:      
<script src="../Js/jquery-1.8.3.min.js" type="text/javascript"></script>    -
    <script src="../Js/jquery-ui-1.10.3.custom.js" type="text/javascript"></script>

    <script src="../Js/gridviewScroll.min.js" type="text/javascript"></script>

    <link href="../CSS/GridviewScroll.css" rel="stylesheet" type="text/css" />

//以上的文件都可以直接到網上下載的

    <script type="text/javascript">

        $(document).ready(function() {
            gridviewScroll();
        });

        function gridviewScroll() {

//  因為我的GRIDVIEW 要放在一個DIV中所以要獲得對應的高度和寬度,一般直接數字設置就好了

            var gridWidth = $("#divservic").width();
            var gridHeight = $("#divservic").height();

            var headerHeight = $("#divHeader").height();

            gridHeight = gridHeight - headerHeight;

            $('#<%=GridView2.ClientID%>').gridviewScroll({
            width: gridWidth,//寬度 一定不能用100%  可直接寫死
            height: gridHeight,//高度  可以直接寫死
            freezesize:4//控制頭幾列不動
            });
        }


復制代碼 代碼如下:
<div id="divservic" style="width: 100%;margin-bottom: 2px; height:220px;">

                            <asp:GridView ID="GridView2" runat="server" CellPadding="4" ForeColor="#333333" Width="100%"
                                BorderColor="#D1DDAA" AllowPaging="True" DataKeyNames="InstallationID"
                                OnPageIndexChanging="GridView2_PageIndexChanging"
                                onrowdatabound="GridView2_RowDataBound"
                                onrowdeleting="GridView2_RowDeleting" AutoGenerateColumns="False"
                                AllowSorting="True" onsorting="GridView2_Sorting">
                                <RowStyle CssClass="GridviewScrollItem"  />>-------------------------------------------------------------這裡的樣式要添加
                                <FooterStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" />
                                <PagerStyle CssClass="GridviewScrollPager"  />-------------------------------------------------------------這裡的樣式要添加
                                <SelectedRowStyle BackColor="#C5BBAF"  />
                                <HeaderStyle CssClass="GridviewScrollHeader" />-------------------------------------------------------------這裡的樣式要添加
                                <EditRowStyle BackColor="#7C6F57" />
                                <AlternatingRowStyle BackColor="White" BorderColor="#D1DDAA" />
                                <Columns>
                                    <asp:TemplateField>
                                        <ItemTemplate>
                                            <asp:CheckBox ID="ckbitem" runat="server" />
                                        </ItemTemplate>

                                    </asp:TemplateField>
                                 <asp:BoundField DataField="InstallationID" HeaderText="InstallationID"
                                        SortExpression="InstallationID" />
                                    <asp:BoundField DataField="Completed" HeaderText="Completed" />
                                    <asp:BoundField DataField="Tid" HeaderText="Tid" />
                                    <asp:BoundField DataField="Mid" HeaderText="Mid" />
                                    <asp:BoundField DataField="Bank" HeaderText="Bank" />
                                    <asp:BoundField DataField="Model" HeaderText="Model" />
                                    <asp:BoundField DataField="Barcode" HeaderText="Barcode" />
                                    <asp:BoundField DataField="DateReq" HeaderText="DateReq"
                                        SortExpression="DateReq" />

                                </Columns>
                            </asp:GridView>
                         </div>

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved