AspNetPager分页控件的使用

        protected void Page_Load(object sender, EventArgs e)
        {
            pager.RecordCount = bm.Count();
            Bind();
        }
        private void Bind()
        {
            PagedDataSource pds = new PagedDataSource();
            pds.AllowPaging = true;
            pds.PageSize = pager.PageSize;
            pds.CurrentPageIndex = pager.CurrentPageIndex - 1;
            pds.DataSource = bm.GetAll().Tables[0].DefaultView;

            DataList1.DataSource = pds;
            DataList1.DataBind();
        }
        protected void pager_PageChanged(object sender, EventArgs e)
        {//分页事件,点击分页会改变CurrentPageIndex的值
            Bind();
        }

JYOnline分页控件在代码中:
1.

DataSet ds = bl.GetByQuery(strWhere, strOrder, AspNetPager1.CurrentPageIndex - 1, AspNetPager1.PageSize);
AspNetPager1.RecordCount = bllArticle.GetByQueryCount(strWhere);
2.protected void AspNetPager1_PageChanging(object src, Wuqi.Webdiyer.PageChangingEventArgs e)
    {
        AspNetPager1.CurrentPageIndex = e.NewPageIndex;
        BindArticle();
    }
3.web.config中<system.web>下添加节点
    <pages>
      <controls>
        <add assembly="AspNetPager" namespace="Wuqi.Webdiyer" tagPrefix="webdiyer"/>
        <add tagPrefix="EZC" assembly="StudyEZ.Controls" namespace="StudyEZ.Controls"/>
      </controls>
    </pages>

AspNetPager分页控件的使用:
        protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            GetAllExams();
        }
    }
        private void GetAllExams()
    {
        PagedDataSource pds = new PagedDataSource();
        DataSet ds=bllpaper.GetAllExam();
        AspNetPager1.RecordCount = ds.Tables[0].Rows.Count;
        pds.AllowPaging = true;
        pds.PageSize = AspNetPager1.PageSize;
        pds.CurrentPageIndex = AspNetPager1.CurrentPageIndex - 1;
        pds.DataSource = ds.Tables[0].DefaultView;
        this.RptExam.DataSource = pds;
        this.RptExam.DataBind();
    }
        protected void AspNetPager1_PageChanging(object src, Wuqi.Webdiyer.PageChangingEventArgs e)
    {
        AspNetPager1.CurrentPageIndex = e.NewPageIndex;
        GetAllExams();
    }

原文地址:https://www.cnblogs.com/cw_volcano/p/1948065.html