title: Selecting an alternate EditorFor template for a List
body: <p>I have an object that represents a food item to order at a restaurant. This object has a list of Modifier Groups (sides, cooking instructions, pizza toppings, whatever) and each list has a list of Modifiers.</p>
  
  <p>Certain Modifier options need to be displayed differently (for example, toppings need to specify left/right/all), even though they are the same data type.</p>
  
  <p>I am trying use @Html.EditorFor and specify the alternate EditorTemplate when required.</p>
  
  <p>In /Views/Shared/EditorTemplates I have ModifierSelection.cshtml and ToppingSelection.cshtml. I am calling them in the following view:</p>
  
  <pre><code>@model MyApp.ViewModels.ModifierSelectionList
  
  &lt;div class="menugroup"&gt;
      &lt;h3 class="menuname"&gt;@Model.ModifierListName: (Select @Model.MaximumSelections)&lt;/h3&gt;
      &lt;div class="modcountvalidation"&gt;@Model.ValidationResults&lt;/div&gt;
      @Html.HiddenFor(model =&gt; Model.ModifierListId)
  
      &lt;table class="menu"&gt;
      @if (Model.IsToppingsList)
      {
          @Html.EditorFor(model =&gt; Model.ModifierSelections, "ToppingSelection")
      }
      else
      { 
          @Html.EditorFor(model =&gt; Model.ModifierSelections)
      }
      &lt;/table&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>When I try to display an item that requires the "ToppingSelection" EditorTemplate instead of the default, I get the following error:</p>
  
  <pre><code>System.InvalidOperationException was unhandled by user code
    Message=The model item passed into the dictionary is of type 'System.Collections.Generic.List`1[MyApp.ViewModels.ModifierSelection]', but this dictionary requires a model item of type 'MyApp.ViewModels.ModifierSelection'.
    Source=System.Web.Mvc
  </code></pre>
  
  <p>So - I have a set of EditorTemplates for a data type. I am trying to use them to display a list of items and I need to be able to select which one to use. </p>
  
  <p>What am I doing wrong?</p>
  
  <p>Thanks!</p>