title: Show a list from a model in MVC razor
body: <p>Can I enumerate a list from the model in the razor?</p>
  
  <p>My model:</p>
  
  <pre><code>public class PreapprovalViewModel
  {
      public int ProjectId { get; set; }
      public int Decision { get; set; }
      public List&lt;BranchHead&gt; BranchHeads { get; set; }
      public List&lt;SelectListItem&gt; Decisions { get; set; }
  }
  </code></pre>
  
  <p>On the index for Preapproval I want a table that shows some fields within the BranchHead list.</p>
  
  <p>Razor:</p>
  
  <pre><code>@model Mars.Intranet.ViewModels.PreapprovalViewModel
  @{
      ViewBag.Title = "Index";
  }
  @Html.Partial("_ProjectPartial")
  &lt;h2&gt;Preapproval&lt;/h2&gt;
  @using (Html.BeginForm()) {
      &lt;div&gt;
          Approve research request:
          @Html.DropDownListFor(o =&gt; o.Decision, Model.Decisions)
      &lt;/div&gt;
      &lt;div id="assign-branch-head" style="display: none;"&gt;
          Assign branch heads
          &lt;table&gt;
              &lt;tr&gt;
                  &lt;th&gt;@Html.DisplayFor(o =&gt; o.BranchHeads.BranchName&lt;/th&gt; &lt;!-- Can I access the list in the model like this?--&gt;
                  &lt;th&gt;@Html.DisplayFor(o =&gt; p.BranchHeads.FirstName&lt;/th&gt; &lt;!-- Can I access the list in the model like this?--&gt;
                  &lt;th&gt;@Html.DisplayFor(o =&gt; p.BranchHeads.Comment&lt;/th&gt; &lt;!-- Can I access the list in the model like this?--&gt;
              &lt;/tr&gt; 
              &lt;tr&gt;
                  &lt;td&gt;&lt;!-- I want the info from the list in model here--&gt;&lt;/td&gt;
                  &lt;td&gt;&lt;!-- I want the info from the list in model here--&gt;&lt;/td&gt;
                  &lt;td&gt;&lt;!-- I want the info from the list in model here--&gt;&lt;/td&gt;
              &lt;/tr&gt;
          &lt;/table&gt;
      &lt;/div&gt;
      &lt;div class="approval-comment"&gt;
          Comment:
          @Html.TextAreaFor(o =&gt; o.Comment)
      &lt;/div&gt;
      &lt;button type="submit" class="btn_submit"&gt;&lt;/button&gt;
  }
  </code></pre>