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.
精彩评论