我有这样的看法:
@model SCWW.Areas.OnlineBookings.Models.Updates.UpdateDetailsModel
@using (Html.BeginForm("Apply", "Updates", new { area = "OnlineBookings", consignmentKey = Model.ConsignmentKey }, FormMethod.Post, new { id = "updateableForm" }))
{
<fieldset>
<legend>Updateable - @Html.DisplayFor(model => model.ConsignmentKey)</legend>
<div class="well well-small ">
@Html.HiddenFor(m => m.ConsignmentKey)
<table id="updateDetails" class="table table-bordered table-striped table-hover dataTable">
<tbody>
<tr>
<td>Completed Date</td>
<td>@Html.CheckBoxFor(m => m.Apply)</td>
<td class="table-input">@Html.TextBoxFor(m => m.CompletedDate, new { Disabled = "Disabled" })</td>
</tr>
<tr>
<td>Cancelled Date</td>
<td>@Html.CheckBoxFor(m => m.Apply)</td>
<td class="table-input">@Html.TextBoxFor(m => m.CancelDate, new { Disabled = "Disabled" })</td>
</tr>
<tr>
<td>Booking Number</td>
<td>@Html.CheckBoxFor(m => m.Apply)</td>
<td class="table-input">@Html.TextBoxFor(m => m.BookingNumber, new { Disabled = "Disabled" })</td>
</tr>
</tbody>
</table>
<button type="submit" id="applyProxy" name="action" value="@FormAction.Apply" class="btn btn-success">Update</button>
</div>
</fieldset>
}
控制器:
[HttpPost]
public ActionResult Apply(UpdateDetailsModel model, FormAction action)
{
if (!ModelState.IsValid)
{
return View("Submit", GenerateViewModel(model.ConsignmentKey));
}
updateableService.Update(model.ConsignmentKey,"CompletedDate", model.ToDto());
return RedirectToActionWithHash("Details", "otherActionsTab", "Bookings",
new { consignmentKey = model.ConsignmentKey });
}
在我看来,有 3 行,每行有一个复选框。当我单击视图上的“更新”按钮时,只选择了一个复选框。我如何知道选择了哪个复选框?如何将选定的复选框值从视图传递到控制器 - 控制器中的 Apply(UpdateDetailsModel model, FormAction action)