复制代码 代码如下:
public void Page_Load(Object src,EventArgs e)
{
OleDbConnection objConn=new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0; Data Source=c:/test.mdb");
OleDbDataAdapter objCommand=new OleDbDataAdapter("select * from Users",objConn);
DataSet ds=new DataSet();
objCommand.Fill(ds);
//对PagedDataSource 对象的相关属性赋值
PagedDataSource objPds = new PagedDataSource();
objPds.DataSource = ds.Tables[0].DefaultView;
objPds.AllowPaging = true;
objPds.PageSize = 5;
int CurPage;
//当前页面从Page查询参数获取
if (Request.QueryString["Page"] != null)
CurPage=Convert.ToInt32(Request.QueryString["Page"]);
else
CurPage=1;
objPds.CurrentPageIndex = CurPage-1;
lblCurrentPage.Text = "Page: " + CurPage.ToString();
if (!objPds.IsFirstPage)
lnkPrev.NavigateUrl=Request.CurrentExecutionFilePath+"?Page="+ onvert.ToString(CurPage-1);
if (!objPds.IsLastPage)
lnkNext.NavigateUrl=Request.CurrentExecutionFilePath+"?Page="+Convert.ToString(CurPage+1);
//把PagedDataSource 对象赋给Repeater控件
Repeater1.DataSource=objPds;
Repeater1.DataBind();
}
新闻热点
疑难解答
图片精选