samedi 28 mai 2016


I am trying to add pagination to my website and followed this guide:

My Controller looks like this:

using PagedList;
using PagedList.Mvc;

public ActionResult Content(int? page)
   int currentPageIndex = page.HasValue ? page.Value - 1 : 0;
   Other code here...
   return View(model.ToPagedList(currentPageIndex, 10));

And my View looks like this:

@using PagedList;
@using PagedList.Mvc;
@model IPagedList<Prj.Models.ContentModels>

@foreach (var content in Model)
   Table code here...
<div class="pager">
   @Html.Pager(Model.PageSize, Model.PageNumber, Model.TotalItemCount)

The problem is however that the @Html.Pager part doesn't seem to work. I get the following error:

'HtmlHelper<IPager<Models>>' does not contain a defintion for 'Pager' and no extension method 'Pager' accepts a first argument of type 'HtmlHelper<IPageList<Models>>' could be found (are you missing a using directive or an assembly reference?)

I have installed both PageList and PageList.Mvc via NuGet.

Aucun commentaire:

Enregistrer un commentaire