zoukankan      html  css  js  c++  java
  • [原创] AspNetPager分页控件的运用

    1. 添别AspNetPager.dll的引用。

    2.    <webdiyer:AspNetPager ID="pager" runat="server" CssClass="Other" PageSize="20" OnPageChanged="pager_PageChanged"
                                                CustomInfoStyle="Other">
                                            </webdiyer:AspNetPager>

    放到Html表格中

    3. 后台代码

    grid是要分页的GridView 或DataGrid 的控件ID

     protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
                PageInit();
        }
        private void PageInit()
        {
            pager.RecordCount = 获取要分页的数据库的行的记录总和

            BindData();

        }

     

      void BindData()
        {     记得要把PageSize ,CurrentPageIndex 两个参数带上
                  grid.DataSource = 获取数据库记录.Get( pager.PageSize * (pager.CurrentPageIndex - 1), pager.PageSize);
                  grid.DataBind();

        }

    分页事件

    protected void pager_PageChanged(object sender, EventArgs e)
        {
            BindData();
        }

    这样就可以了

  • 相关阅读:
    软件公司项目经理岗位职责
    指针和链表
    数据结构
    五子棋
    AtCoder Grand Contest 031 B
    两道dp
    博客搬迁
    [Codeforces Round #526 (Div. 2)]
    [Educational Codeforces Round 55 (Rated for Div. 2)][C. Multi-Subject Competition]
    [codeforces Mail.Ru Cup 2018 Round 3][B Divide Candies ][思维+数学]
  • 原文地址:https://www.cnblogs.com/JamesLi2015/p/1318185.html
Copyright © 2011-2022 走看看