加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > asp.Net > 正文

asp.net-mvc-3 – 在脚手架视图MVC3中进行分页

发布时间:2020-12-16 06:30:08 所属栏目:asp.Net 来源:网络整理
导读:所以使用EF4我创建了一个脚手架控制器/视图,所以我的问题是如何以简单/快速的方式将Paging添加到我的视图? 该 控制器生成 public ViewResult Index() { return View(db.Perifericos.ToList()); } 该 视图:生成 @model IEnumerablePaginacion.Models.Perife
所以使用EF4我创建了一个脚手架控制器/视图,所以我的问题是如何以简单/快速的方式将Paging添加到我的视图?

控制器生成

public ViewResult Index()
        {
            return View(db.Perifericos.ToList());
        }


视图:生成

@model IEnumerable<Paginacion.Models.Perifericos>

<p>
    @Html.ActionLink("Create New","Create")
</p>
<table>
    <tr>
        <th>
            Nombre
        </th>
        <th>
            Modelo
        </th>
    </tr>

@foreach (var item in Model) {
    <tr>
        <td>
            @Html.DisplayFor(modelItem => item.Nombre)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.Modelo)
        </td>
        <td>
            @Html.ActionLink("Edit","Edit",new { id=item.idPerifericos }) |
            @Html.ActionLink("Delete","Delete",new { id=item.idPerifericos })
        </td>
    </tr>
}
</table>

解决方法

也许这可以帮到你: http://www.asp.net/entity-framework/tutorials/sorting-filtering-and-paging-with-the-entity-framework-in-an-asp-net-mvc-application

您必须在控制器中实现分页,并在视图中添加代码,例如我给您的链接.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读