I am trying to create an Editortemplate for a List<Package>. I am fully qualifying the type in my Editortemplate view as such:
@model List<JYP.Business.ViewModels.Package>
When I try to reference Model within my Editortemplate view, I am getting a null reference which leads me to believe that the model isn’t getting associated properly. I had to use a UIHint in my ViewModel in order to have it use the Editortemplate at all. My ViewModel contains a List<Package> Packages which is what I am trying to have my custom Editortemplate pick up. What am I doing wrong?
You could rely on conventions:
and then in your main view:
and then you could define an editor template which will be automatically rendered for each element of the Packages collection:
By convention this editor template should be placed in the
~/Views/SomeController/EditorTemplates/Package.cshtmlor~/Views/Shared/EditorTemplates/Package.cshtml. Those are the 2 locations that ASP.NET MVC will look for it in that order.