asp.net repeater手写分页实例代码 复制代码 代码如下:using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using BLL; using Model; using System.Data.SqlClient; using System.Data; public partial class Test_RepeaterFENYE : System.Web.UI.Page { private readonly static CategoryBLL cb = new CategoryBLL(); private readonly static Category_Info cgi = new Category_Info(); int Menu_ID = 0; protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { BindData(); } } private void BindData() { IList li = cb.GetAllCategory(); if (li.Count > 0) { PagedDataSource pds = new PagedDataSource(); pds.DataSource = li; pds.AllowPaging = true; pds.PageSize =2; int curPage; if (Request.QueryString["page"] != null) { curPage = Convert.ToInt32(Request.QueryString["page"]); } else { curPage = 1; } pds.CurrentPageIndex = curPage - 1; this.Repeater1.DataSource = pds; this.Repeater1.DataBind(); this.Label4.Text = ""; this.Label4.Text += "共有" + li.Count.ToString() + "条记录 "; this.Label4.Text += "每页显示" + pds.PageSize + " "; this.Label4.Text += "" + pds.PageCount.ToString() + " "; this.Label4.Text += "当前第" + curPage.ToString() + " "; if (curPage == 1) { this.Label4.Text += "首页 "; this.Label4.Text += "上一页 "; } else { //this.Label4.Text += "首页 "; //this.Label4.Text += "上一页 "; this.Label4.Text += "首页 "; this.Label4.Text += "上一页 "; } if (curPage == pds.PageCount) { this.Label4.Text += "下一页 "; this.Label4.Text += "尾页 "; } else { this.Label4.Text += "下一页 "; this.Label4.Text += "尾页 "; //this.Label4.Text += "下一页 "; //this.Label4.Text += "尾页 "; } string HtmlSelectString = ""; this.Label4.Text += "" + HtmlSelectString + ""; } else { Label4.Text = "没有数据!"; } } } 注://注释部分为url rewrite的效果。。。li返回的值为SQL查询后所得到表中所有的记录。。。