public ActionResult Index(int?Page_No) { List <ArtworkViewModel> collection = new List <ArtworkViewModel>(); var pagedData = new PagedDataSet <ArtworkViewModel>(); int pageSize = 10; try { using (ViewModels.ArtworkViewModel ViewModel = new ArtworkViewModel()) { var pageNumber = (Page_No.HasValue) ? ((Page_No.Value >= 1) ? Page_No.Value : 0) : 0; pagedData = ViewModel.GetDataPagination(pageNumber); // model = new PagedList<ArtworkViewModel>(collection, Page_No.HasValue?Page_No.Value:1, pageSize); // //collection.ToPagedList(pageValue, 10); // model.PageCount = ViewModel.GetData().Count(); // obj = ViewModel.GetDataPagination(Page_No); } } catch (Exception ex) { throw ex; } return(View(pagedData)); }
// GET: ArtWorks //public ActionResult Index() //{ // List<ArtworkViewModel> collection = new List<ArtworkViewModel>(); // try // { // using (ViewModels.ArtworkViewModel ViewModel = new ArtworkViewModel()) // { // collection = ViewModel.GetData(); // } // } // catch (Exception ex) // { // throw ex; // } // return View(collection); //} public ActionResult GetDataPagination(int?Page_No) { List <ArtworkViewModel> collection = new List <ArtworkViewModel>(); var pagedData = new PagedDataSet <ArtworkViewModel>(); int pageSize = 10; try { using (ViewModels.ArtworkViewModel ViewModel = new ArtworkViewModel()) { var pageNumber = (Page_No.HasValue) ? ((Page_No.Value >= 1) ? Page_No.Value : 0) : 0; pagedData = ViewModel.GetDataPagination(pageNumber); //pick coilumns you need var selectedData = (from p in pagedData.Items select new { ArtWorkID = p.ArtWorkID , ArtTitle = p.ArtTitle , Location = p.CurrenTLocation.Value } ).ToList(); // model = new PagedList<ArtworkViewModel>(collection, Page_No.HasValue?Page_No.Value:1, pageSize); // //collection.ToPagedList(pageValue, 10); // model.PageCount = ViewModel.GetData().Count(); // obj = ViewModel.GetDataPagination(Page_No); } } catch (Exception ex) { throw ex; } return(View(pagedData.Items.ToPagedList(pageNumber: Page_No ?? 1, pageSize: 10))); }