I have View Model List like this:
public class PersonViewModel
{
int PersonId
bool LikesIceCream
}
The View will display a list of people and their preference to ice cream – like it or don’t.
I’m not sure how to construct the html in a way that I can use the RadioButtonFor HTML helper and properly pass the values back to the controller. Simply creating RadioButtonFor’s in a foreach loop doesn’t help because they will have the same name. Any idea how I can hook these values up with the model binder?
Thanks.
View model:
Controller:
View (
~/Views/Home/Index.cshtml):Editor template (
~/Views/Home/EditorTemplates/PersonViewModel.cshtml):