AspNetPager进行分页

   <p><webdiyer:AspNetPager ID="anp" runat="server" onpagechanging="anp_PageChanging" PageSize="5"
                           UrlPaging="True">
    </webdiyer:AspNetPager></p>

 

 

  private void NewsList()
    {
        DataSet da = new DataSet();
        DataTable dt = new DataTable();

        dt= new NewCom().Sidtitledatetime();
        da.Tables.Add(dt);
        anp.RecordCount = da.Tables[0].DefaultView.Count;
        PagedDataSource pd = new PagedDataSource();
        pd.DataSource = da.Tables[0].DefaultView;
        pd.AllowPaging = true;
        pd.PageSize = 50;
      pd.CurrentPageIndex =anp.CurrentPageIndex - 1;
      pd.PageSize = anp.PageSize;
      Repnewslist.DataSource = pd;
      Repnewslist.DataBind();
    }
    protected void anp_PageChanging(object src, Wuqi.Webdiyer.PageChangingEventArgs e)
    {
        anp.CurrentPageIndex = e.NewPageIndex;
        NewsList();
    }
}

你可能感兴趣的:(PAGER)