I'm looking to have something like the following:
@foreach(var option in ViewBag.OptionsAvailable)
{
//the 'option' variable will be used in these fields, of course
<input type='checkbox' name='thingToUse' />
<input type='text' name='textToSaveForThing' />
}
ViewBag.OptionsAvailable can be of variable length. I would like to take one of these options and add it to Model.Options with the saved value IF its checkbox is selected. The idea here is that, on the HttpPost controller method, I want to only acknowledge/save the value in the textbox if its corresponding checkbox is selected. What's the best way to approach this?
I've come across this explanation of binding to a list, but I'm not sure how to evolve upon that to create what I want.
optionvariable used?