Using a PagedList with a ViewModel ASP.Net MVC

For anyone who is trying to do it without modifying your ViewModels AND not loading all your records from the database. Repository public List<Order> GetOrderPage(int page, int itemsPerPage, out int totalCount) { List<Order> orders = new List<Order>(); using (DatabaseContext db = new DatabaseContext()) { orders = (from o in db.Orders orderby o.Date descending //use orderby, … Read more

How to I apply filter while paginating in Asp.net MVC and entity Framework?

Your form needs to post back to the GET method, and that method needs to include parameters for your filter properties. Your PagedListPager code in the view also need to include those filter properties so they are retained when you navigate to the next/previous page. Note that the Index() POST method is not used and … Read more