I have an MVC4 view that hosts a Kendo ListView. The ViewModel contains the properties required by the ListView as well as properties used by the main view. Problem is the ListView uses an IEnumerable of the ViewModel and my main view doesn’t. Seems I can’t have both in 1 view (or can I?).
For example
The MVC view that loads in the listview as a partial view binds to the following model:
@model app.WebSiteModels.EditPhotoViewModel
where EditPhotoViewModel is defined as :
public class EditPhotoViewModel
{
public WebsitePhoto WebsitePhoto { get; set; } //WebsitePhoto is used in my main view
public IEnumerable<Photo> PhotoList { get; set; } //the Photo properties are used in my listview
}
The listview binds to an IEnumerable version of EditPhotoViewModel:
@model IEnumerable
Problem:
@model app.WebSiteModels.EditPhotoViewModel doesn’t work with the viewlist
and
@model IEnumerable<app.WebSiteModels.EditPhotoViewModel> doesn’t work with my main view
I must be missing something pretty basic here – please assist asap as I have been trying to figure this out for a few days now and this is urgent.
You can bind the ListView to the PhotoList property. Here is how: