title: EditorFor IEnumerable<T> with TemplateName
body: <p>Suppose I have a simple model to explain the purpose:</p>
  
  <pre class="lang-cs prettyprint-override"><code>public class Category
  {
      ...
      public IEnumerable&lt;Product&gt; Products { get; set; }
  }
  </code></pre>
  
  <p>View:</p>
  
  <pre class="lang-cs prettyprint-override"><code>@model Category
  ...
  &lt;ul&gt;
      @Html.EditorFor(m =&gt; m.Products)
  &lt;/ul&gt;
  </code></pre>
  
  <p>EditorTemplate:</p>
  
  <pre class="lang-cs prettyprint-override"><code>@model Product
  ...
  &lt;li&gt;
      @Html.EditorFor(m =&gt; m.Name)
  &lt;/li&gt;
  </code></pre>
  
  <p>Note that I don't have to define the EditorTemplate for <code>IEnumerable&lt;Product&gt;</code>, I can only create it for the <code>Product</code> model and MVC framework is smart enough to use its own template for IEnumerable. It iterates through my collection and calls my EditorTemplate.</p>
  
  <p>The output html will be something like this</p>
  
  <pre class="lang-html prettyprint-override"><code>...
  &lt;li&gt;
      &lt;input id="Products_i_Name" name="Products[i].Name" type="text" value="SomeName"&gt;
  &lt;/li&gt;
  </code></pre>
  
  <p>which I can post to my controller after all.</p>
  
  <p>But why doesn't the MVC do the trick when I define EditorTemplate with a template name?</p>
  
  <pre class="lang-cs prettyprint-override"><code>@Html.EditorFor(m =&gt; m.Products, "ProductTemplate")
  </code></pre>
  
  <p>In that case I have to change the type of the property to <code>IList&lt;Product&gt;</code>, iterate through the collection by myself and call the EditorTemplate</p>
  
  <pre class="lang-cs prettyprint-override"><code>@for (int i = 0; i &lt; Model.Products.Count; i++)
  {
      @Html.EditorFor(m =&gt; m.Products[i], "ProductTemplate")
  }
  </code></pre>
  
  <p>which seems kind of dirty workaround to me. Is it any other, cleaner solution to do this?</p>