mercredi 4 février 2015

Model binding dynamic amount of textboxes and checkboxes

I have a view which I want to let users use to create new items on my site. The view has a couple of fields which do not change in amount, but it has a feature which allows users to add as many textboxes and checkboxes as they need. Each textbox and checkbox belongs to a viewmodel with a string field and a bool field, and each new set of textbox/checkboxes will be used to create another instance of that viewmodel


Here's a graph that better explains what I'm looking to do:


Explination


I then need to submit this to a controller using a simple HTML form. Problem is, I don't know how to bind the prop3 list to the dynamically generated textboxes/checkboxes. Prop1 and Prop2 are fine, as I can just use @HTML.TextBoxFor. What do I do for the dynamically generated textboxes/checkboxes?





Aucun commentaire:

Enregistrer un commentaire