分页功能,打算使用第三方控件AspNetPager,这是个很不错的国产分页控件使用也很简单,aspx页面:
1、<%@ Register Assembly="AspNetPager" Namespace="Wuqi.Webdiyer" TagPrefix="webdiyer" %>2、<webdiyer:AspNetPager ID="AspNetPager1" runat="server" Width="100%" HorizontalAlign="right" PageSize="10" OnPageChanged="AspNetPager1_PageChanged">
</webdiyer:AspNetPager>
aspx.cs:
1、AspNetPager1.RecordCount = 总记录数;
2、分页事件:protected void AspNetPager1_PageChanged(object src, EventArgs e){...}
3、AspNetPager1.CurrentPageIndex获取当前页
=========================================================目前看上去很好,但是如果哪天,找到一个更好的控件,或者这个控件大升级了,那么上面那些东西都要改了,从设计思想角度,想把他封装起来,在aspx,aspx.cs中,完全不会有AspNetPager的东西,仅需要传递记录数,页数等参数。简单的说,就是要求如果以后更换分页控件,只需要改一个地方,不用改全部页面。思路是这样,但是不会做,没弄懂的几个地方:1、aspx中,“<%@ Register Assembly="AspNetPager" Namespace="Wuqi.Webdiyer" TagPrefix="webdiyer" %>”如何“封装”
2、“分页事件:protected void AspNetPager1_PageChanged”如何“封装”?
3、“AspNetPager1”如何“传递”?
1、<%@ Register Assembly="AspNetPager" Namespace="Wuqi.Webdiyer" TagPrefix="webdiyer" %>2、<webdiyer:AspNetPager ID="AspNetPager1" runat="server" Width="100%" HorizontalAlign="right" PageSize="10" OnPageChanged="AspNetPager1_PageChanged">
</webdiyer:AspNetPager>
aspx.cs:
1、AspNetPager1.RecordCount = 总记录数;
2、分页事件:protected void AspNetPager1_PageChanged(object src, EventArgs e){...}
3、AspNetPager1.CurrentPageIndex获取当前页
=========================================================目前看上去很好,但是如果哪天,找到一个更好的控件,或者这个控件大升级了,那么上面那些东西都要改了,从设计思想角度,想把他封装起来,在aspx,aspx.cs中,完全不会有AspNetPager的东西,仅需要传递记录数,页数等参数。简单的说,就是要求如果以后更换分页控件,只需要改一个地方,不用改全部页面。思路是这样,但是不会做,没弄懂的几个地方:1、aspx中,“<%@ Register Assembly="AspNetPager" Namespace="Wuqi.Webdiyer" TagPrefix="webdiyer" %>”如何“封装”
2、“分页事件:protected void AspNetPager1_PageChanged”如何“封装”?
3、“AspNetPager1”如何“传递”?
重写Render输出分页
http://www.cnblogs.com/iRed/archive/2009/08/28/1555728.html
[ASP.NET服务器控件]OranPager 1.1.1.2 - 轻量级分页控件(URL参数机制,不带数据查询功能)演示&源码
作者也来了,顶一下。AspNetPager是非常优秀的组件,感谢!
顺便提下意见,演示网站的效果很好,但是如果能每个演示能配上代码就更好了