C#
public ActionResult BiaoDan(int? page) { int pageindex = 1; if (page > 0) { pageindex = (int)page; } var pagesize = 6; pageindex = pageindex - 1; var db = new ddrDBEntities(); var rowcount = db.BiaoDan.Count(); if (rowcount < 1) { return Content("暂时没有客户的留言信息返回"); } if (page < 1) { return Redirect("/admin/biaodan/?page=1"); } var pagecount = rowcount / pagesize; if(rowcount % pagesize >0) { pagecount +=1; } if (pageindex+1 > pagecount) { return Redirect( string.Format("/admin/biaodan/?page={0}",pagecount)); } var objs = db.BiaoDan .OrderByDescending(m=>m.ShiJian) .Skip(pageindex*pagesize) .Take(pagesize) .ToList(); db.Dispose(); return View(objs); } public JsonResult DelBiaoDan() { var objid = Guid.Parse(Request["delid"]); using (var db = new ddrDBEntities()) { var obj = db.BiaoDan.Where(m => m.Id == objid).FirstOrDefault(); db.BiaoDan.DeleteObject(obj); db.SaveChanges(); } var result = new JsonResult(); result.JsonRequestBehavior = JsonRequestBehavior.AllowGet; result.Data = new { flag = true }; return result; } }
CSHTML