public ActionResult Index(int? page, FormCollection collection)
{
query = GetClients(collection);
var pagedView= new PaginatedList<Clients>(query, page ?? 0, pageSize);
return View(pagedView);
}
The above works if i am on page 1. When i click on page 2 link it fails for the reason that 'collection param is null and GetClients returns all the records rather then what I am search against.
The form collection has the following text box:First Name, Company Name, Zip
Is there a way to keep the query returned in session and then during each paging event, check the session object and if it has the IQueryable object then extract from it else call GetClients(collection)
Update 1: My updated code
public ActionResult Index(int? page, FormCollection collection)
{
ClientSearch clientSearch = new ClientSearch();
this.UpdateModel(clientSearch, new[] { "FName",Lane",Zip","Phone"});
query = GetClients(clientSearch);
var pagedView= new PaginatedList<Clients>(query, page ?? 0, pageSize);
return View(pagedView);
}