When you enable paging and sorting in MVC WebGrid, it automatically adds the sorting and page options to the query string automatically. How does it do it? I understand how it creates a link for page n, but how to do this if you read the query string to find out which page to produce?
What really bothers me is that in the controller I do not need to specify the page and sort options, but they work anyway. What kind of witchcraft is this?
if I was not clear enough
here is a grid definition
@{ var grid = new WebGrid(Model.Customers, rowsPerPage: 25, canPage: true }); }
here is the query string that is created:
/Customer?sort=Notes&sortdir=ASC
and my Customer.Index controller
public ActionResult Index()
{
...
}
getit source
share