I have a ViewModel with a list how can I remove the list elements using checkboxes? I generate checkboxes with a foreach in the edit action, but how can I get the checkboxes' value beside the ViewModel with HttpPost?
<dl>
@foreach (var flower in Model.FlowerList)
{
<dt><input type="checkbox" id="@flower.Id"/></dt>
<dd>@flower.Name</dd>
}
</dl>
With this code down I can get only the viewmodel's values, but not the checkboxes' because they are not part of the viewmodel.
[HttpPost]
[ValidateAntiForgeryToken]
public override ActionResult Edit(int id, BouquetViewModel viewModel)
{
if (!ModelState.IsValid)
{
return View(viewModel);
}
DataService.Update(viewModel);
return RedirectToAction("Details/" + id);
}
Aucun commentaire:
Enregistrer un commentaire