在config文件上写上这两句话然后,在连接的地方写上注:我的数据库是放在App_Data文件夹下数据库命为temp.mdbDataSet分页可以调用该函数///
/// 分页控件
///
///
///
///
public static void PageDataSet(Wuqi.Webdiyer.AspNetPager anp, Repeater rpt, DataSet ds)
{
ds.Tables[0].Columns.Add("IndexID", System.Type.GetType("System.Int32"));
for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
{
ds.Tables[0].Rows[i]["IndexID"] = Convert.ToString(i + 1);
}
DataView dv = ds.Tables[0].DefaultView;
anp.RecordCount = dv.Count;
PagedDataSource pds = new PagedDataSource();
pds.DataSource = dv;
pds.AllowPaging = true;
pds.CurrentPageIndex = anp.CurrentPageIndex - 1;
pds.PageSize = anp.PageSize;
rpt.DataSource = pds;
rpt.DataBind();
}在pageload以及aspnetpager的pagechanged事件里分别调用该函数即可,aspnetpager不要开启url分页!