zoukankan      html  css  js  c++  java
  • GridView 自定义分页

    1. 默认分页方式
    (1) 是否允许分页
    GridView的AllowPaging属性。

    (2) 每页记录数
    GridViewPageSize

    (3) 分页导航条形式
    GridViewPagerSettings属性的Mode:Numeric,NextPrevious,NextPreviousFirstLast,NumericFirstLast。

    (4)GridViewOnPageIndexChanging="GridView1_PageIndexChanging 
    2. 自定义分页
    (1) 当前页
    <asp:Label  ID="LabelCurrentPage" runat="server" 
     Text
    ="<%# ((GridView)Container.NamingContainer).PageIndex + 1 %>"></asp:Label> 


    (2) 总页数
    <asp:Label ID="LabelPageCount" runat="server" 
     Text
    ="<%# ((GridView)Container.NamingContainer).PageCount %>"></asp:Label> 


    (3) 首页、上一页、下一页、尾页
    <asp:LinkButton ID="LinkButtonFirstPage" runat="server" CommandArgument="First" CommandName="Page" 
     Visible
    ="<%# ((GridView)Container.NamingContainer).PageIndex != 0 %>">首页</asp:LinkButton> 

    <asp:LinkButton ID="LinkButtonPreviousPage" runat="server" CommandArgument="Prev" CommandName="Page" 
     Visible
    ="<%# ((GridView)Container.NamingContainer).PageIndex != 0 %>">上一页</asp:LinkButton> 

    <asp:LinkButton ID="LinkButtonNextPage" runat="server" CommandArgument="Next" CommandName="Page" 
     Visible
    ="<%# ((GridView)Container.NamingContainer).PageIndex != ((GridView)Container.NamingContainer).PageCount - 1 %>">下一页</asp:LinkButton> 

    <asp:LinkButton ID="LinkButtonLastPage" runat="server" CommandArgument="Last" CommandName="Page" 
     Visible
    ="<%# ((GridView)Container.NamingContainer).PageIndex != ((GridView)Container.NamingContainer).PageCount - 1 %>">尾页</asp:LinkButton> 
     

    注:将上面自定义的代码写在GridView的<PagerTemplate></PagerTemplate>标签内即可。

    CS页面

       protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
          {
              GridView1.PageIndex = e.NewPageIndex;
              DataBind();
          }

  • 相关阅读:
    [转]HD钱包的助记词与密钥生成原理
    [转]简单科普私钥、地址、助记词、Keystore的区别
    [转]Sequelize 中文API文档-4. 查询与原始查询
    [转]Node.JS使用Sequelize操作MySQL
    [转]OmniLayer / omnicore API 中文版
    [转]usdt omnicore testnet 测试网络
    [转]USDT与omniCore钱包
    [转]BTC RPC API GetTransaction
    [转]比特币测试链——Testnet介绍
    [转]BTC手续费计算,如何设置手续费
  • 原文地址:https://www.cnblogs.com/kingboy/p/1040825.html
Copyright © 2011-2022 走看看