I have a view like this:
@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>
}
Controller:
[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 });
}
In my view there 3 rows each with one checkbox. Only one checkbox is seleted when i click "update" button on View. How would i get to know which checkbox is selected? How to pass the selected checkbox value from view to controller - Apply(UpdateDetailsModel model, FormAction action) in controller