日期:2014-05-17 浏览次数:20512 次
public void Paging(DataSet ds, int pagesize) { PagedDataSource pds = new PagedDataSource(); //创建分页对象 pds.DataSource = ds.Tables[0].DefaultView; //绑定分页数据 pds.AllowPaging = true; //开启分页 int pagerowsize = pagesize;//每页显示几行 int datarocount = this.ds.Tables[0].Rows.Count; // 数据集中共有多少行 int totalpage = pds.PageCount;//总页数 int pagedqindex = pds.CurrentPageIndex;//当前页索引 int pagepor = pagedqindex - 1;//上一页 int pageext = pagedqindex + 1;//下一页 int strat = 0; if (Request.QueryString["page"] != null) //判断请求页面的参数是否为空,为空则表示当前还没分过页 { pds.CurrentPageIndex = Convert.ToInt32(Request.QueryString["page"]); strat = Convert.ToInt32(Request.QueryString["page"]) / 5 * 5; end = strat + 5; } else { end = 5; } for (int i = strat; i <=end; i++) { if (i == totalpage) { break; } this.kje_con_fylb.InnerHtml += "<span class=\"kje_con_fyin\"><a href=\"" + HttpContext.Current.Request.CurrentExecutionFilePath + "?page=" + i + "\">" + i + "</a> </span>"; } kje_con_fylb.InnerHtml += "<span class=\"kje_con_fyin\">共" + totalpage + "页</span>"; this.DataList1.DataSource = pds; this.DataList1.DataBind();