首页 > 代码库 > 分页效果
分页效果
搞定分页效果,虽然不完善,呵,用着,足够了.from:www.sysoft.cc
using System;using System.Collections.Generic;using System.Linq;using System.Web;using System.Web.UI;using System.Web.UI.WebControls;using System.Text;namespace SysoftSite{ public partial class Pager : System.Web.UI.UserControl { protected string Html; private int pagecount; public int Pagecount { get { return pagecount; } set { pagecount = value; } } private int pageindex; public int Pageindex { get { return pageindex; } set { pageindex = value; } } protected void Page_Load(object sender, EventArgs e) { if (pagecount <= 1) { Html = "[1]"; return; } int start = 0; if (pagecount > 10 && pageindex + 4 > pagecount) { start = pageindex - (10-((pagecount-pageindex)+1)); } else { start = pageindex - 5; } if (start < 1) { start = 1; } int end = start + 9; if (end > pagecount) { end = pagecount; } StringBuilder sb = new StringBuilder(); for (int i = start; i <=end; i++) { if (i == pageindex) { sb.AppendFormat(" [" + i + "] "); } else { sb.AppendFormat(" <a href=http://www.mamicode.com/?pageindex="+i+">[" + i + "]</a> "); } } Html = sb.ToString(); } }}
分页效果
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。