public ActionResult MultipleMvcPagers(int id = 1,int pageIndex=1) { const int pageSize = 5; var model=new CompositeArticles(); model.ArticleList1 = DemoData.AllArticles.OrderByDescending(a => a.PubDate).ToPagedList(pageIndex, pageSize); model.ArticleList2 = DemoData.AllArticles.OrderByDescending(a => a.PubDate).ToPagedList(id, pageSize); return View(model); }
public ActionResult MultipleAjaxPagers(int id = 1,int pageIndex=1) { using (var db = new DataContext()) { var pageSize = 5; var model = new CompositeArticles(); model.ArticleList1 = db.Articles.OrderByDescending(a => a.PubDate).ToPagedList(pageIndex, pageSize); model.ArticleList2 = db.Articles.OrderByDescending(a => a.PubDate).ToPagedList(id, pageSize); return View(model); } }
public ActionResult AjaxPagers(int id = 1, int pageIndex = 1, int page = 1) { using (var db = new DataContext()) { const int pageSize = 5; if (Request.IsAjaxRequest()) { var target = Request.QueryString["target"]; if (target == "articles") { return PartialView("_AjaxArticles1", db.Articles.OrderByDescending(a => a.PubDate).ToPagedList(id, pageSize)); } if (target == "articles2") { return PartialView("_AjaxArticles2", db.Articles.OrderByDescending(a => a.PubDate).ToPagedList(pageIndex, pageSize)); } return PartialView("_AjaxArticles3", db.Articles.OrderByDescending(a => a.PubDate).ToPagedList(page, pageSize)); } var model = new CompositeArticles { ArticleList1 = db.Articles.OrderByDescending(a => a.PubDate).ToPagedList(id, pageSize), ArticleList2 = db.Articles.OrderByDescending(a => a.PubDate).ToPagedList(pageIndex, pageSize), ArticleList3 = db.Articles.OrderByDescending(a => a.PubDate).ToPagedList(page, pageSize) }; return View(model); } }