gpt4 book ai didi

asp.net-mvc-3 - 在脚手架 View MVC3 中分页

转载 作者:行者123 更新时间:2023-12-05 00:02:30 25 4
gpt4 key购买 nike

所以使用 EF4 我创建了一个脚手架 Controller / View ,所以我的问题是如何以简单/快速的方式将分页添加到我的 View 中?

Controller 生成

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

您必须在 Controller 中实现分页,并在 View 中添加代码,如我提供给您的链接。

关于asp.net-mvc-3 - 在脚手架 View MVC3 中分页,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7921546/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com