Monday 11 December 2017

Model Item type ambiguity when using PagedList

The problem is that this line:
return View(questionList.Questions.ToPagedList(pageNumber, pageSize));
Is sending a model of type IPagedList down to the page (because the extension method is being applied to a type of List), but your page says it is expecting:
@model PagedList.IPagedList<SWSSMVC.Models.ViewModels.QuestionListViewModel>
Changing your view code to say this instead should fix it:
@model PagedList.IPagedList<SWSSMVC.Models.ViewModels.QuestionViewModel>

No comments:

Post a Comment

Note: only a member of this blog may post a comment.