Is it possible to list a list from a model in a razor?
My model:
public class PreapprovalViewModel
{
public int ProjectId { get; set; }
public int Decision { get; set; }
public List<BranchHead> BranchHeads { get; set; }
public List<SelectListItem> Decisions { get; set; }
}
In the index for Preapproval, I want a table that shows some fields in the BranchHead list.
Razor:
@model Mars.Intranet.ViewModels.PreapprovalViewModel
@{
ViewBag.Title = "Index";
}
@Html.Partial("_ProjectPartial")
<h2>Preapproval</h2>
@using (Html.BeginForm()) {
<div>
Approve research request:
@Html.DropDownListFor(o => o.Decision, Model.Decisions)
</div>
<div id="assign-branch-head" style="display: none;">
Assign branch heads
<table>
<tr>
<th>@Html.DisplayFor(o => o.BranchHeads.BranchName</th>
<th>@Html.DisplayFor(o => p.BranchHeads.FirstName</th>
<th>@Html.DisplayFor(o => p.BranchHeads.Comment</th>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
</tr>
</table>
</div>
<div class="approval-comment">
Comment:
@Html.TextAreaFor(o => o.Comment)
</div>
<button type="submit" class="btn_submit"></button>
}
Carel source
share