編輯器載入中...asp.net urlpager控制項使用攻略
1、引入UrlPager.dll
2、在web.config中添加
3、註冊路由(在Global檔案中)
using System.Web.Routing;//引入命名空間
在Application_Start中調用方法
void Application_Start(object sender, EventArgs e)
{
RegisterRoutes(RouteTable.Routes);
}
編寫註冊路由方法
public static void RegisterRoutes(RouteCollection routes)
{
routes.MapPageRoute("UrlPagingRepeater",
"{controller}/{action}/page_{id}",
"~/orderde.aspx");
routes.MapPageRoute("UrlPagingBasic",
"Home/{pageIndex}",
"~/Default.aspx");
}
4、主要是aspx頁面上
引入控制項
添加控制項
5、主要是cs檔案中
調用控制項的PageChanged事件進行操作
如:infos = orderInfo.SearchOrder(this.pager1.StartRecordIndex, this.pager1.EndRecordIndex);
6、剛開始要先編寫預存程序
ALTER procedure [dbo].[GetOrderPager]
@startIndex INT,
@endindex INT
AS
begin
WITH orderList AS (
select ROW_NUMBER() OVER (ORDER BY orderid DESC)AS Row,* from [Order].OrderInfo
where 1=1
)
select * from orderlist
WHERE Row between @startIndex and @endIndex
end
徹底完成!