GridView 真分頁 自寫控制項

2021-06-20 04:38:55 字數 1960 閱讀 7093

由於gridview自身必須載入所有資料,才能正常顯示。對於資料量很大的情況下,載入比較慢,所有自己寫了個分頁控制項,不再使用gridview裡面的pageindex和pagecount,用viewstate儲存,從而達到真分頁,儲存過程用row_number實現分頁

0" operator="greaterthan" type="integer" validationgroup="webuserpager"

valuetocompare="0">

protected void page_prerender(object sender, eventargs e)

protected void pagerbutton_click(object sender, commandeventargs e)

}else

viewstate["pageindex"] = 0;

break;

}binddata();

}public void refreshui()

else

else if (int.parse(viewstate["pageindex"].tostring()) == pagecount - 1)

}this.lblpageinfo.text = viewstate["pagesummery"] as string;

}

create procedure ...  

@workorder nvarchar(50)

, @productno nvarchar(50)

, @imei nvarchar(50)

, @createdatefrom datetime

, @createdateto datetime

, @createman nvarchar(50)

, @pagecount int

, @currentpageindex int

as with temp as (

select row_number() over (order by createdate desc) as rowid,* from ...

where (workorder=@workorder or @workorder is null) and (productno=@productno or @productno is null) and

(imei=@imei or @imei is null) and (createman=@createman or @createman is null) and

(createdate>=@createdatefrom or @createdatefrom is null) and (createdate<=@createdateto or @createdateto is null)

) select * from temp where rowid between (@currentpageindex-1)*@pagecount+1 and @currentpageindex*@pagecount

select count(*) from dbo.csms_feibaoworkorder

where (workorder=@workorder or @workorder is null) and (productno=@productno or @productno is null) and

(imei=@imei or @imei is null) and (createman=@createman or @createman is null) and

(createdate>=@createdatefrom or @createdatefrom is null) and (createdate<=@createdateto or @createdateto is null)

go

gridView分頁控制項

using system using system.collections.generic using system.linq using system.web using system.web.ui.webcontrols using system.drawing using system.tex...

用gridview寫分頁

根據pagecount和pageindex實現分頁功能以及刪除提示 protected void gridview1 rowcreated object sender,gridviewroweventargs e if e.row.rowtype datacontrolrowtype.pager i...

GridView控制項分頁顯示資料

using system using system.collections.generic using system.linq using system.web using system.web.ui using system.web.ui.webcontrols using system.conf...