title: Making HTML Tables in MVC4 using Strongly typed models
body: <p>I am attempting to make an HTML Table with data I pull out of DB...</p>
  
  <p>Here is my Model...</p>
  
  <pre><code>public class PopulationModels
  {
      public List&lt;PopulationModel&gt; Populations { set; get; }
  }
  </code></pre>
  
  <p>Which is simply a list of...</p>
  
  <pre><code>public class PopulationModel
  {
      public string populationID { set; get; }
  
      public string PopName { set; get; }
  
      public string Description { set; get; }
  
      public string PopulationType { set; get; }
  
      public Boolean isActive { set; get; }
  
      //public List&lt;XSLTACOData&gt; patients { set; get; }
  }
  </code></pre>
  
  <p>I pass this model to my view like so...</p>
  
  <pre><code>IEnumerable&lt;PopulationModels&gt; PopModel = DataRepo.Get(userName);
  return View(PopModel);
  </code></pre>
  
  <p>I attempt to show a list in the following way...</p>
  
  <pre><code>@foreach (var item in Model) {
  &lt;tr&gt;
      &lt;td class="rowControl hidden"&gt;
          @*&lt;a href="#makeRowEditable" class="makeRowEditable"&gt;Edit&lt;/a&gt;*@ |
          @*&lt;a href="#deleteRow" class="deleteRow"&gt;Delete&lt;/a&gt;*@
          @Html.DispalyFor(modelItem =&gt; item.Populations)
      &lt;/td&gt;
  &lt;/tr&gt;
  }
  </code></pre>
  
  <p>But I am having a hard time figuring out how to access the individual elements of my model...</p>
  
  <p>For instance</p>
  
  <pre><code>@Html.DispalyFor(modelItem =&gt; item.Populations)
  </code></pre>
  
  <p>The above line of code, I want to take each individual populationModel and map a column for each of the fields... But I can't seem to access the individual populations... Am I missing a logical step here (I obviously am, but which step?)</p>
  
  <p>UPDATE:  ADDING SOME MORE OF THE VIEW:  I am making now getting a table, but the way I am doing it seems counter intuitive...</p>
  
  <p>Here is my model...</p>
  
  <pre><code> @model IEnumerable&lt;FocusedReadMissionsRedux.Models.PopulationModels&gt;
  </code></pre>
  
  <p>Here is how I am creating my table (I am planning on using jqGrid's tableToGrid functionality as soon as I can get a solid way to access my data...</p>
  
  <pre><code>&lt;table border="2"&gt;
  &lt;thead&gt;
    &lt;tr&gt;
    &lt;th&gt;
      Population Name
    &lt;/th&gt;
     &lt;th&gt;
      Population Description
    &lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  @foreach(var item in Model){
  foreach (var pop in item.Populations)
  {
  &lt;tr&gt;
      &lt;td class="rowControl hidden"&gt;
          @Html.DisplayFor(modelItem =&gt; pop.PopName)
          @Html.ActionLink(pop.PopName,"","")
      &lt;/td&gt;
      &lt;td&gt;
          @Html.DisplayFor(modelItem =&gt; pop.Description)
          @Html.Display(pop.Description)
      &lt;/td&gt;
  &lt;/tr&gt;
  }
  </code></pre>
  
  <p>}
   </p>