利用aspnetpager分页控件,将其与Gridview绑定

protected void Pager(GridView gv, Wuqi.Webdiyer.AspNetPager anp, DataTable dt2)
{
PagedDataSource pds = new PagedDataSource();
pds.DataSource = dt2.DefaultView;
pds.AllowPaging = true;

anp.RecordCount = dt2.DefaultView.Count;
pds.CurrentPageIndex = anp.CurrentPageIndex - 1;
pds.PageSize = anp.PageSize;

gv.DataSource = pds;
gv.DataBind();
}

你可能感兴趣的:(GridView)