PagedList of ViewModel object?

Aug 5, 2010 at 4:49 AM

Hi,

I created a ViewModel class called ReviewViewModel.

I want to page through some ReviewViewModel objects using the MvcPager.

However I can't seem to get my ReviewViewModel into a PagedList.

I keep getting this error:

Cannot implicitly convert type 'System.Collections.Generic.IEnumerable<Project1.Model.ReviewViewModel>' to 'Webdiyer.WebControls.Mvc.PagedList<Project1.Model.ReviewViewModel>'. An explicit conversion exists (are you missing a cast?) 

Any idea what I'm doing wrong?

Thanks!

 

 

Coordinator
Aug 10, 2010 at 3:42 AM

You can use ToPagedList<T> extension method to convert IEnumerable<T> collection to PagedList<T>, or use constrctors of PagedList<T> to construct it, please take a look at code in the sample project. thanks!

Aug 11, 2010 at 4:44 AM

I got it.  It makes sense.


Thanks for your work!