I need to update a list of checkboxes based on the following ViewModel:
namespace ViewModels
{
public class MemberProfileListViewModel
{
public IList<MemberProfileDetailViewModel> MemberProfileDetails { get; set; }
}
public class MemberProfileDetailViewModel
{
public int Id { get; set; }
public string Name { get; set; }
public bool Selected { get; set; }
}
}
The View:
@model ViewModels.MemberProfileListViewModel
@using (Html.BeginForm()) {
<fieldset>
@foreach (var item in ??????)
{
<p>@Html.CheckBoxFor(????)</p>
}
<p>
<input type="submit" value="Save" />
</p>
</fieldset>
}
The Controller:
public virtual ActionResult EditProfiles()
{
var memberProfileListDto = _memberProfileService.ListByMember(WebSecurity.CurrentUserId);
var memberProfileListViewModel = Mapper.Map<MemberProfileListDto, MemberProfileListViewModel>(memberProfileListDto);
return View(memberProfileListViewModel);
}
How do I make the list of the checkboxes with the Id to make the update back to the controller?
Thanks.
Currently
foreachis not supported in this context. Try usingforconstruct,