点击删除链接(这是一个按钮)没有任何反应。我的意思是表格没有发布。不知道为什么会发生这种情况。
@foreach (var item in Model) {
<tr>
<td>
@Html.DisplayFor(modelItem => item.RegistrationNo)
</td>
<td>
@Html.DisplayFor(modelItem => item.FirstName)
</td>
<td>
@Html.DisplayFor(modelItem => item.MiddleName)
</td>
<td>
@Html.DisplayFor(modelItem => item.LastName)
</td>
<td>
@Html.DisplayFor(modelItem => item.DateofBirth)
</td>
<td>
@Html.ActionLink("Edit", "Edit", new { id=item.Id }) |
@Html.ActionLink("Details", "Details", new { id=item.Id }) |
<input type="submit" value="Delete" name="Delete" style="border: none; background: none;
text-decoration: underline; cursor: pointer;">
</td>
</tr>
答案 0 :(得分:1)
这是你可以尝试的东西
@using (Html.BeginForm()) {
<table>
@foreach (var item in Model) {
<tr>
<td>
@Html.DisplayFor(modelItem => item.RegistrationNo)
@Html.HiddenFor(modelItem => item.RegistrationNo)
</td>
<td>
@Html.DisplayFor(modelItem => item.FirstName)
@Html.HiddenFor(modelItem => item.FirstName)
</td>
<td>
@Html.DisplayFor(modelItem => item.MiddleName)
@Html.HiddenFor(modelItem => item.MiddleName)
</td>
<td>
@Html.DisplayFor(modelItem => item.LastName)
@Html.HiddenFor(modelItem => item.LastName)
</td>
<td>
@Html.DisplayFor(modelItem => item.DateofBirth)
@Html.HiddenFor(modelItem => item.DateofBirth)
</td>
<td>
@Html.ActionLink("Edit", "Edit", new { id=item.Id }) |
@Html.ActionLink("Details", "Details", new { id=item.Id }) |
<input type="submit" value="Delete" name="Delete" style="border: none; background: none;
text-decoration: underline; cursor: pointer;">
</td>
</tr>
</table>
}