修改以前做的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由頁面定義)