修改以前做的ASCX用户组件,改编成真正意义的组件,用于制作ASP.NET中的DBGrid,DBList,Repeater等的自定义分页,配合存储过程,能提供高效的的分页功能。
属性:
Number:记录总数;
PageSize:每页显示数量;
CurrentPage:当前页码(只读)
事件:
翻页时触发PageChanged事件;
演示代码:
public class WebForm1 : System.Web.UI.Page
{
protected AspControls.PageUpDown PageUpDown2;
private void Page_Load(object sender, System.EventArgs e)
{
if (!Page.IsPostBack)
{
PageUpDown2.Number = 300;
PageUpDown2.PageSize = 30;
}
}
private void PageUpDown1_PageChanged(object sender, System.EventArgs e)
{
Response.Write(PageUpDown2.CurrentPage);
}
override protected void OnInit(EventArgs e)
{
this.PageUpDown2.PageChanged += new AspControls.PageUpDown.PageEventHandler(this.PageUpDown1_PageChanged);
this.Load += new System.EventHandler(this.Page_Load);
}
}
显示效果:(CSS由页面定义)
[url=http://dayuer.com/dayuer/posts/2322.aspx]下载