I adapted this code Has anyone implement RadioButtonListFor<T> for ASP.NET MVC? for combobox.
But I've a small problem is some case(which appears with checkbox/radiobutton:
If The item I want to bind is in a list, I get weird names:
//Here I've some for loop
@Html.CheckBoxListFor(m => m.Variables[i].Values[j].Triggers)
And I got:
<input id="Variables.get_Item(value(ASP._Page_Areas_Advertiser_Views_Campaign_ValueDependency_cshtml+<>c__DisplayClass2).i).Values.get_Item(value(ASP._Page_Areas_Advertiser_Views_Campaign_ValueDependency_cshtml+<>c__DisplayClass4).j).Triggers_103" name="Variables.get_Item(value(ASP._Page_Areas_Advertiser_Views_Campaign_ValueDependency_cshtml+<>c__DisplayClass2).i).Values.get_Item(value(ASP._Page_Areas_Advertiser_Views_Campaign_ValueDependency_cshtml+<>c__DisplayClass4).j).Triggers.ListItems[0].Selected" type="checkbox" value="true" />
How to avoid this name?
EDIT: The list of item is dynamic and has to be loaded from the controller:
pulic ActionResult DoMyThing(){
_dataStore.MakeThings();
....
MyModel model = new MyModel{SelectedId=5, AvailableObjects= _aPreviouslyLoadedList};
return View(model);
}