展开全部
完整代码(Access+asp.net),你稍微看下很简单的,改点东西就可以用了,同样试用Repeater控件
OleDbConnection con =new OleDbConnection("Provider=Microsoft.Jet.OleDB.4.0;" + "Data Source="+Server.MapPath("~/DataBase/DB.mdb"));
con.Open();
OleDbDataAdapter da = new OleDbDataAdapter(你的SQL语句,con);
DataSet ds = new DataSet();
da.Fill(ds,"News");
//创建分页类
PagedDataSource objPage = new PagedDataSource();
//设置数据源
objPage.DataSource = ds.Tables["News"].DefaultView;
//开启分页
objPage.AllowPaging = true;
//显示显示的行数
objPage.PageSize = 20;
//定义变量保存当前页索引
int curPage;
//判断当前页是否有跳转请求
if (Request.QueryString["Page"] != null)
curPage = Convert.ToInt32(Request.QueryString["Page"]);
else
curPage = 1;
objPage.CurrentPageIndex = curPage - 1;
this.Label1.Text = curPage.ToString();
this.Label2.Text = objPage.PageCount.ToString();
if (!objPage.IsFirstPage)
{ //定义"上一页"超级连接的URL为:当前执行页面的虚拟路径,并传递下一页面的索引植
this.HyperLink1.NavigateUrl = Request.CurrentExecutionFilePath + "?name=" + Request.QueryString["name"]+"&Page="+Convert.ToString(curPage - 1);
}
if (!objPage.IsLastPage)
{
//下一页
this.HyperLink2.NavigateUrl = Request.CurrentExecutionFilePath + "?name=" + Request.QueryString["name"]+"&Page="+Convert.ToString(curPage + 1);
}
this.HyperLink3.NavigateUrl = Request.CurrentExecutionFilePath + "?name=" + Request.QueryString["name"]+"&Page=" + Convert.ToString(objPage.PageCount);
this.DataList1.DataSource = objPage;
this.DataList1.DataBind();
OleDbConnection con =new OleDbConnection("Provider=Microsoft.Jet.OleDB.4.0;" + "Data Source="+Server.MapPath("~/DataBase/DB.mdb"));
con.Open();
OleDbDataAdapter da = new OleDbDataAdapter(你的SQL语句,con);
DataSet ds = new DataSet();
da.Fill(ds,"News");
//创建分页类
PagedDataSource objPage = new PagedDataSource();
//设置数据源
objPage.DataSource = ds.Tables["News"].DefaultView;
//开启分页
objPage.AllowPaging = true;
//显示显示的行数
objPage.PageSize = 20;
//定义变量保存当前页索引
int curPage;
//判断当前页是否有跳转请求
if (Request.QueryString["Page"] != null)
curPage = Convert.ToInt32(Request.QueryString["Page"]);
else
curPage = 1;
objPage.CurrentPageIndex = curPage - 1;
this.Label1.Text = curPage.ToString();
this.Label2.Text = objPage.PageCount.ToString();
if (!objPage.IsFirstPage)
{ //定义"上一页"超级连接的URL为:当前执行页面的虚拟路径,并传递下一页面的索引植
this.HyperLink1.NavigateUrl = Request.CurrentExecutionFilePath + "?name=" + Request.QueryString["name"]+"&Page="+Convert.ToString(curPage - 1);
}
if (!objPage.IsLastPage)
{
//下一页
this.HyperLink2.NavigateUrl = Request.CurrentExecutionFilePath + "?name=" + Request.QueryString["name"]+"&Page="+Convert.ToString(curPage + 1);
}
this.HyperLink3.NavigateUrl = Request.CurrentExecutionFilePath + "?name=" + Request.QueryString["name"]+"&Page=" + Convert.ToString(objPage.PageCount);
this.DataList1.DataSource = objPage;
this.DataList1.DataBind();
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询