zoukankan      html  css  js  c++  java
  • MVC3分页

    引用MVCPaging.dll来进行分页,不过不同的MVC的版本一定要下载不同的MVCPaging.dll来使用。否则在MVC3里面会不兼容的。

    Controller:
            using MvcPaging;
     
            public ActionResult Index(int? page)
            {
                var list = VideoRepository.FindAll().OrderByDescending(v => v.CreateTime);
                return View(list.ToPagedList(page.HasValue ? page.Value - 1 : 0, 3));
            }
    View:
    @model IPagedList<Funny.Models.Video>
    @using MvcPaging;
     
    @{
        ViewBag.Title = "Index";
        Layout = "~/Views/Shared/_Layout.cshtml";
    }
    <h1>
        Video<span>Some of our favorite Big Cartel stores.</span></h1>
    <div id="main">
        <ul class="block-video">
            @foreach (var item in Model)
            {
                <li><a href="#">
                    <img src="/Content/videos/@item.ImageName" alt="picture" /></a>
                    <h4>
                        @item.Title</h4>
                    <p>
                        <a href="#">@item.Description</a>
                    </p>
                </li>
            }
        </ul>
        <div class="pager">
        @Html.Pager(Model.PageSize,Model.PageNumber,Model.TotalItemCount)
        </div>
    </div>
     
    Last,don't forget fix css style.
     
    /* pager */
    .pager
    {
        margin:8px 30px;
        padding:3px;
    }
    .pager .disabled
    {
        border:1px solid #ddd;
        color:#999;
        margin-top:4px;
        padding:3px;
        text-align:center;
    }
    .pager .current
    {
        border:0px hidden;
        font-weight:bold;
        margin-top:4px;
        padding:3px 5px;
        text-align:center;
    }
    .pager span, .pager a
    {
        margin: 4px 3px;
    }
    .pager a
    {
        border:1px solid #c0c0c0;
        padding:3px 5px;
        text-align:center;
        text-decoration:none;
    }
  • 相关阅读:
    MySQL 5.1.73升级为MySQL 5.5.35详解
    MySQL 常用show命令
    MySQL 用户与授权管理详解
    MySQL 日志管理详解
    MySQL 5.5.35 单机多实例配置详解
    mysql启动与关闭(手动与自动)
    hduTHE MATRIX PROBLEM(差分约束)
    在 iPad和 iPhone的浏览器上查看网页源代码
    《30天自制操作系统》之——第3天
    python network programming tutorial
  • 原文地址:https://www.cnblogs.com/bianlan/p/2476657.html
Copyright © 2011-2022 走看看