0

I am using the Webgrid in asp.net mvc3, and using it's build in paging and sorting.

@{
    var grid = new WebGrid(rowsPerPage: 10, ajaxUpdateContainerId: "GridDiv");
    grid.Bind(source: Model);
    grid.Pager(WebGridPagerModes.All);
}

The paging in the bottom shows something like this to switch between pages

1 2 3 4 5 >

When there is less then 10 rows in the model, there is only one page and the paging in the bottom disappear.

is there a way to make it show even if there is only one page?

1 >

Hope I was clear. Thanks a lot

Y2theZ
  • 10,162
  • 38
  • 131
  • 200
  • @Youssef....it's working for me when I have fewer rows than the page size. The only difference I can see in my code is canPage: true is an attribute in the WebGrid definition. Try new WebGrid(rowsPerPage: 10, ajaxUpdateContainerId: "GridDiv", canPage:true); Don't know if that will help but it's worth a shot – MikeTWebb Apr 05 '12 at 15:00
  • and what do you want the links to have ? "1 >" ?? – Yasser Shaikh Apr 06 '12 at 06:27
  • @Yasser nothing. I just want that footer to show. because I am adding to it some more links. so when there is only one page the entire footer dissapear. – Y2theZ Apr 06 '12 at 10:05
  • did this work ? http://stackoverflow.com/questions/10030893/webgrid-show-the-paging-even-if-there-is-only-one-page/10040038#10040038 – Yasser Shaikh Apr 06 '12 at 10:42

1 Answers1

0

One quick fix would be to check the TotalRowCount and manually add links,

@{
var grid = new WebGrid(rowsPerPage: 10, ajaxUpdateContainerId: "GridDiv");
grid.Bind(source: Model);
grid.Pager(WebGridPagerModes.All);

if(grid.TotalRowCount <= 10)
{
<a href="#">1</a>
<a href="#">></a>
}
}

this definitely is not a correct way to do so, also what are you planning to do on clicks on such links? are they just empty links then this is for you.

Yasser Shaikh
  • 46,934
  • 46
  • 204
  • 281