title: Using Html.DisplayFor in mvc with templates
body: <p>I have a model</p>
  
  <pre><code>public class Person {
      public string Name { get; set; }
      public int Age { get; set; }
  }
  </code></pre>
  
  <p>and a Simple View</p>
  
  <pre><code>&lt;%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage&lt;IList&lt;Site.Models.Person&gt;&gt;" %&gt;
  &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
  &lt;head runat="server"&gt;
  &lt;/head&gt;
  &lt;body&gt;
      &lt;% for (int i = 0 ; i &lt; Model.Count ; i++) {  %&gt;
          &lt;%: Html.DisplayFor(m =&gt; m[i])%&gt;
      &lt;% } %&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>With a Partial View</p>
  
  <pre><code> &lt;%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl&lt;Site.Models.Person&gt;" %&gt;
   &lt;h1&gt;A person&lt;/h1&gt;
   &lt;div&gt;Name: &lt;%: Html.DisplayFor(x =&gt; x.Name)%&gt;&lt;/div&gt;
   &lt;div&gt;Age: &lt;%: Html.DisplayFor(x =&gt; x.Age)%&gt;&lt;/div&gt;
  </code></pre>
  
  <p>and single Controller </p>
  
  <pre><code>public ActionResult Index () {
          Person p1 = new Person { Age = 18 , Name = "jon" };
          Person p2 = new Person { Age = 23 , Name = "bob" };
  
          return View(new List&lt;Person&gt; { p1 , p2 });
      }
  </code></pre>
  
  <p>The Displayfor in the view should show each person displayed with the Template specified in the partial view, but it is not. Thanks for any help</p>