为什么我的表单会像这样加载?
这是我的代码:
@using MvcApplication6.Models;
@model List<Employee>
@{
ViewBag.Title = "Index";
}
<h2>Index</h2>
<p>
<a href="@Url.Action("Create")">Create Entry</a>
</p>
<p>@Html.ActionLink("Check departments", "Index", "Department")</p>
<p><a href="@Url.Action("Summary")">Check summary</a></p>
<table border="1">
<tr>
<th>
@Html.DisplayNameFor(model => model[0].id)
</th>
<th>
@Html.LabelFor(model => model[0].firstname)
</th>
<th>
@Html.LabelFor(model => model[0].lastname)
</th>
<th>
@Html.DisplayNameFor(model => model[0].gender)
</th>
<th>
@Html.DisplayNameFor(model => model[0].department)
</th>
<th>Action</th>
</tr>
@using (Html.BeginForm())
{
@Html.AntiForgeryToken()
@Html.ValidationSummary(true)
foreach (Employee mod in Model)
{
<tr>
<td>
<input type="hidden" value="@mod.id" name="id" id="id" />
@Html.DisplayFor(modelItem => mod.id)
</td>
<td>
@Html.DisplayFor(modelItem => mod.firstname)
</td>
<td>
@Html.DisplayFor(modelItem => mod.lastname)
</td>
<td>
@Html.DisplayFor(modelItem => mod.gender)
</td>
<td>
@Html.DisplayFor(modelItem => mod.department)
</td>
<td>
<button onclick="location.href='@Url.Action("Edit", new { id = mod.id })';return false;">Edit</button>
@Html.CheckBoxFor(modelItem => mod.selected)
</td>
</tr>
}
<br />
<input type="submit" value="submit" />
}
</table>
以下是我的担忧:
请注意,我在submit
循环之后放置了foreach
按钮,但是如何在实际框之前首先渲染它?
我一直试图把它放在底部,但我遇到了一些问题。
渲染的顺序是什么?