I have what appears (to me anyway) to be a strange problem...
I created a simple editor template for a SelectListItem (SelectListItem.cshtml in the ~/Views/Shared/EditorTemplates folder), for example:
<ul class="select-list-item cell-15 col-3 omega clearfix">
@Html.EditorFor(c => c.Categories)
</ul>
Where c.Categories is an IEnumerable
This worked fine, but I wanted another template to render the collection with slightly different markup, so I copied and renamed the editor template to, for example, 'CategoryIcons.cshtm' and invoked as follows:
<ul class="select-list-item cell-15 col-3 omega clearfix">
@Html.EditorFor(c => c.Categories, "CategoryIcons")
</ul>
In short, the only difference is I'm specifying a named editor template.
When I open the page, I now get the following error:
The model item passed into the dictionary is of type 'System.Collections.Generic.List`1[System.Web.Mvc.SelectListItem]', but this dictionary requires a model item of type 'System.Web.Mvc.SelectListItem'
The template's model declaration, in both templates id:
@model System.Web.Mvc.SelectListItem
I don't understand why the default template works and the named template doesn't. Any help would be appreciated.
Thanks.
SelectListItem
with a class of any other name and use that to get a different template, but in either case, this is probably a good place for someone looking to add to MVCContrib to start. – Shrove