日期:2014-05-19  浏览次数:20450 次

gridview手动分页例子
自动分页效率低,哪为朋友给个手动分页的例子或者控件呢
要求显示:当前页   共**页面   首页   上   下   尾页   跳转到


------解决方案--------------------
控制好数据集的大小会更方便一些
------解决方案--------------------
//分页开始
objpage = new PagedDataSource();
DataView dv = ds.Tables[0].DefaultView;

objpage.DataSource = dv;
dv.Sort = "State,PlanID desc ";
objpage.AllowPaging = true;
objpage.PageSize = 8;
int curpage = 0;
if (Request.QueryString[ "Page "] != null)
curpage = Convert.ToInt32(Request.QueryString[ "Page "]);
else
curpage = 1;
objpage.CurrentPageIndex = curpage - 1;
try
{
if (objpage.IsFirstPage && !objpage.IsLastPage)
{
this.hlProv.NavigateUrl = " ";
this.hlFirst.NavigateUrl = " ";
this.hlProv.ForeColor = System.Drawing.Color.Black;
this.hlFirst.ForeColor = System.Drawing.Color.Black;
this.hlNext.NavigateUrl = url + "?page= " + Convert.ToInt32(curpage + 1) + "&shopID= " + shopID;
this.hlLast.NavigateUrl = url + "?page= " + Convert.ToInt32(objpage.PageCount) + "&shopID= " + shopID;
}
else
{
if (objpage.IsLastPage && !objpage.IsFirstPage)
{
this.hlFirst.NavigateUrl = url + "?page= " + 1 + "&shopID= " + shopID;
this.hlLast.NavigateUrl = " ";
this.hlNext.NavigateUrl = " ";
this.hlLast.ForeColor = System.Drawing.Color.Black;
this.hlNext.ForeColor = System.Drawing.Color.Black;
this.hlProv.NavigateUrl = url + "?page= " + Convert.ToInt32(curpage - 1) + "&shopID= " + shopID;
}
else
{
if (objpage.IsFirstPage && objpage.IsLastPage)
{
this.hlLast.NavigateUrl = " ";
this.hlNext.NavigateUrl = " ";
this.hlProv.NavigateUrl = " ";
this.hlFirst.NavigateUrl = " ";
this.hlLast.ForeColor = System.Drawing.Color.Black;
this.hlNext.ForeColor = System.Drawing.Color.Black;
this.hlProv.ForeColor = System.Drawing.Color.Black;
this.hlFirst.ForeColor = System.Drawing.Color.Black;
}
else
{
this.hlFirst.NavigateUrl = url + "?page= " + 1;
this.hlLast.NavigateUrl = url + "?page= " + Convert.ToInt32(objpage.PageCount) + "&shopID= " + shopID;
this.hlNext.NavigateUrl = url + "?page= " + Convert.ToInt32(curpage + 1) + "&shopID= " + shopID;
this.hlProv.NavigateUrl = url + "?page= " + Convert.ToInt32(curpage - 1) + "&shopID= "