protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
DataLoad();
}
}
#region 页面数据加载,主要靠这里实现获取分页
private void DataLoad()
{
string strSqlCom = "SELECT * FROM [FileUpLoad] ORDER BY [FilePicid] asc";
linkdata linkdata = new linkdata();//这是一个数据库类 我另外篇数据库操作类里有详细代码。
DataSet ds = linkdata.ExceDS(strSqlCom);
DataView dv = ds.Tables[0].DefaultView;
PagedDataSource pds = new PagedDataSource();
pds.DataSource = dv;
pds.AllowPaging = true;
AspNetPager1.RecordCount = dv.Count;
pds.CurrentPageIndex = AspNetPager1.CurrentPageIndex - 1;
pds.PageSize = AspNetPager1.PageSize;
Rp_photo.DataSource = pds;
Rp_photo.DataBind();
}
#endregion
protected void AspNetPager1_PageChanged(object sender, EventArgs e)
{
DataLoad(); //结束了
}
就这么简单```