ViewModel with PagedList Property - Maintain State

Feb 7, 2011 at 1:13 PM


My view is bound to a Model which contains a properties for all the controls on the page, checkboxes etc. that work to filter results. One of the properties is the PageList that contains the results



 public class SearchResultModel
        public int PriceLow { get; set; }
        public int PriceHigh { get; set; 

        public PagedList<MyType> MyResults{ get; set; }




I can call the initial set of page results ok but


Model must be type PageList which means to get it to work I have to pass

<%=Html.Pager(MySearchResultsModel.Results) %>

The problem with this is that when the Model goes back to the controller is not the full SearchResultsModel so I don't have access to the state of all the other controls on the page which I need
to perform the search again. i.e. in my example PriceLow / PriceHigh

For Html.Pager to work can it only be bound to model containing the data and nothing else?
Apr 9, 2011 at 8:26 AM

Please upgrade to the latest version,(1.5), you don't need to pass PagedList<T> from you controller, just implement IPagedList interface for your model object and it's OK.