开发者

ASP.NET MVC 3 WebGrid paging issue

开发者 https://www.devze.com 2023-01-24 23:16 出处:网络
My data access layer returns collection with rows for single page and total number of rows. Unfortunately WebGrid component does not allow to specify t开发者_开发问答otal number of rows or total numb

My data access layer returns collection with rows for single page and total number of rows.

Unfortunately WebGrid component does not allow to specify t开发者_开发问答otal number of rows or total number of pages (these properties are read-only).

Has anyone had to deal with this issue before?


You can use the Bind method on the WebGrid to tell the grid to use server side paging.

grdv.Bind(myData, rowCount=10000, autoSortAndPage=False)

Setting autoSortAndPage to false tells the grid that myData is just a segment of the data. It will show all rows of this data regardless of your page size setting. Pager will be built using the rowCount you pass in and not the number of records in myData.


EDIT: I see what your question is now. Check out this article for not using the WebGrid.

Paging with WebGrid

From this page, it looks like you can specify rows per page.

var grid = new WebGrid(source, rowsPerPage : 25);

And this page (look at line 9 from the first code block).


rowsPerPage is only settable through the constructor. This was done to keep the helper simple and avoid handling complex states. Total rows comes from the data source.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号