那个朋友有URL分页的例子
给提供个,学习学习.
------解决方案--------------------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= " + Convert.ToString(CurPage-1);
if (!objPds.IsLastPage)
lnkNext.NavigateUrl=Request.CurrentExecutionFilePath+ "?Page= " + Convert.ToString(CurPage+1);
//把PagedDataSource 对象赋给Repeater控件
Repeater1.DataSource=objPds;
Repeater1.DataBind();
}
------解决方案--------------------string cstring= "provider=Microsoft.Jet.OleDb.4.0;Data Source= "+Server.MapPath( ". ")+ "..\\data.mdb; ";
string sql= "select * from pic order by 时间 desc ";
OleDbConnection Mycon=new OleDbConnection(cstring);
Mycon.Open();
OleDbDataAdapter Adpater=new OleDbDataAdapter(sql,Mycon);
DataSet ds=new DataSet();
Adpater.Fill(ds, "pic ");
PagedDataSource a=new PagedDataSource();
a.DataSource=ds.Tables[0].DefaultView;
a.AllowPaging=true;
a.PageSize=1;
int PageSize=a.PageSize;
int TotalRecords=ds.Tables[0].Rows.Count;
int TotalPages = TotalRecords / PageSize;
int curpage;
if(Request.QueryString[ "page "]!=null)
curpage=Convert.ToInt32(Request.QueryString[ "page "]);
else
curpage=1;
a.CurrentPageIndex=curpage-1;
lb1.Text= "当前页 "+curpage.ToString();
lbcount.Text= "共 "+a.PageCount.ToString();
if(!a.IsFirstPage)
//lnkprev.NavigateUrl=Request.CurrentExecutionFilePath+ "?Page= "+ Convert.ToString(curpage-1);
lnkprev.NavigateUrl=Request.CurrentExecutionFilePath+ "?Page= "+ Convert.ToString(curpage-1);
lnkfirst.NavigateUrl=Request.CurrentExecutionFilePath + "?Page= " + 1;
if(!a.IsLastPage)
lnknext.NavigateUrl=Request.CurrentExecutionFilePath+ "?Page= "+ Convert.ToString(curpage+1);
lnklast.NavigateUrl=Request.CurrentExecutionFilePath+ "?Page= " + Convert.ToString(TotalPages);
dp.DataSource=a;
dp.DataBind();
}