title: ASP.net MVC - Display Template for a collection
body: <p>I have the following model in MVC:</p>
  
  <pre><code>public class ParentModel
  {
      public string Property1 { get; set; }
      public string Property2 { get; set; }
  
      public IEnumerable&lt;ChildModel&gt; Children { get; set; }
  }
  </code></pre>
  
  <p>When I want to display all of the children for the parent model I can do:</p>
  
  <pre><code>@Html.DisplayFor(m =&gt; m.Children)
  </code></pre>
  
  <p>I can then create a ChildModel.cshtml display template and the DisplayFor will automatically iterate over the list. </p>
  
  <p>What if I want to create a custom template for IEnumerable?</p>
  
  <pre><code>@model IEnumerable&lt;ChildModel&gt;
  
  &lt;table&gt;
      &lt;tr&gt;
          &lt;th&gt;Property 1&lt;/th&gt;
          &lt;th&gt;Property 2&lt;/th&gt;
      &lt;/tr&gt;
      ...
  &lt;/table&gt;
  </code></pre>
  
  <p>How can I create a Display Template that has a model type of <code>IEnumerable&lt;ChildModel&gt;</code> and then call <code>@Html.DisplayFor(m =&gt; m.Children)</code> without it complaining about the model type being wrong?</p>