samedi 28 novembre 2015

why error Method not found: 'Int32 PagedList.IPagedList.get_PageIndex() occurs

I am working on Paging in Mvc 3, but when i trying to run the page it gives me error

Method not found: 'Int32 PagedList.IPagedList.get_PageIndex()

Here is my code:

public class EmployeeController : Controller
{
    private myContext db = new myContext();

    public ViewResult Index(int? page)
    {
        int pageSize = 20;
        int pageNumber = (page ?? 1);
        return View(db.tbMovie.OrderByDescending(t=> t.Movie_ID).ToPagedList(pageNumber,pageSize));
    }
}

Here is View

@using PagedList.Mvc;
@using PagedList;
@model IPagedList<Cmedia.Models.Employee>

@foreach (var item in Model)
{
    @Html.DisplayFor(modelItem => item.EmployeeID)
    &nbsp;
    @Html.DisplayFor(modelItem => item.EmployeeName)
    <br>
}
Page @(Model.PageCount < Model.PageNumber ? 0 : Model.PageNumber) of @Model.PageCount
@Html.PagedListPager(Model, page => Url.Action("Index", new { page }))

Everything looks fine, but i am still getting error.

Aucun commentaire:

Enregistrer un commentaire