I have three ViewModels:
- QuestionViewModel
Theese two inherit from QuestionViewModel
- MCQViewModel
- MatrixViewModel
I send a list of QuestionViewModel to my View and DisplayForModel renders the correct View, which is in the folder Shared/EditorTemplates.
This all works really well, but now i want to use paging, to show only 2 QuestionViewModel’s at a time.
This is the paging class:
public class PagedData<T> where T : class
{
public IEnumerable<T> Data { get; set; }
public int NumberOfPages { get; set; }
public int CurrentPage { get; set; }
public int CategoryID { get; set; }
}
PagedData would look like this:
PagedData<QuestionViewModel> data = new PagedData<QuestionViewModel>();
I add the List of QuestionViewModel’s to the Data property of PagedData and pass this to my View.
What should i write in:
@model
or the View, To make it render the correct ViewModel ?
Thanks
I found the answer myself.
The way to do it is: