4

so using EF4 I create a scaffolding controller/view, so my question is how can I Add Paging to my view in easy/fast way?? the controller generated

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

the view: generated

@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>
Diego_DX
  • 1,051
  • 1
  • 20
  • 33

3 Answers3

4

Maybe this can help you: http://www.asp.net/entity-framework/tutorials/sorting-filtering-and-paging-with-the-entity-framework-in-an-asp-net-mvc-application

You have to implement a paging in controller and in the view add code like the link that i have given to you.

2

I use this one http://blogs.taiga.nl/martijn/2008/08/27/paging-with-aspnet-mvc/ It's support also ajax and areas

Easy to implement.

Michael Kopljan
  • 177
  • 1
  • 3
  • 12
1

a complete msdn article with sample code

Sorting, Filtering, and Paging with the Entity Framework in an ASP.NET MVC Application

Iman
  • 17,932
  • 6
  • 80
  • 90