日期:2014-05-17 浏览次数:20530 次
public ActionResult Index(int? id = 1)
{
var count = db.Manager.Count();
var article = db.Manager.OrderByDescending(m => m.ID)
.Skip(5 * Convert.ToInt32(id - 1))
.Take(5);
ViewBag.Current = id;
ViewBag.Count = (count % 5 == 0) ?
(count / 5) : count / 5 + 1;
return View(article);
//var managerslist = db.Manager.ToList();
//return View(managerslist);
}
@Html.Pager(1, current, count, 5)
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Entity;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using XikeCompany.Models;
using System.Text;
using System.Web.Routing;
namespace System.Web.Mvc
{
public static class WebPager
{
/// <summary>
/// 创建分页链接
/// </summary>
/// <param name="helper">HtmlHelper类</param>
/// <param name="startPage">开始页 (多数情况下是 1)</param>
/// <param name="currentPage">当前页</param>
/// <param name="totalPages">总页数</param>
/// <param name="pagesToShow">前后显示的页数</param>
public static Mv