Change your view to:
@for (int i = 0; i < Model.Services.Count; i++)
{
@Html.CheckBoxFor(m => m.Services[i].Subscribed)
@Html.HiddenFor(m => m.Services[i].ServiceId)
@Html.HiddenFor(m => m.Services[i].ServiceName)
@Html.DisplayFor(m => m.Services[i].ServiceName)
<br />
}
You need to use the indexer (
[i]
) rather than the
ElementAt
method.
You'll also need to add a hidden field to pass the service name back to the controller.
You might also need to move the initialization out of the
RegistrationModel
constructor, since that will also be called when the posted values are being loaded.