0

In Umbraco / MVC, my model is inheriting from a list of a custom model MyCustomModel,

@inherits Umbraco.Web.Mvc.UmbracoViewPage<List<MyCustomModel>>

That model contains a bool which I want to bind to a checkbox using @HTML.CheckBoxFor. Normally if the model was not a list I would do this:

@Html.CheckBoxFor(x => @Model.isSelected)

But as it is a list I have

 @foreach (MyCustomModel _model in Model)
 {
    <label>@_module.ItemName</label>
    @Html.CheckBoxFor(x => @_model.isSelected)
 }

Although this shows the correct data as it is on the page load, when I then iterate through the list model after checking some checkboxes, nothing has actually changed.

I think I may be able to do it using the index of the current item, something like

x => x[i].isSelected

How would I do this properly?

DarkW1nter
  • 2,933
  • 11
  • 67
  • 120

0 Answers0