I have an asp mvc 2 app lication where I want to display a list of checkboxes that the user can select based on the list of records in the database. To display a list, my model contains a List object, and the view has a foreach and outputs an Html.CheckBox for each item in the list.
Is there a way to get a model filled with selected checkboxes, given that the model cannot have specific properties for each checkbox because the list is dynamic? Or do I need to manually manually iterate over form variables?
Edit: additional data according to sabanito comment
Therefore, in a simple view / simulation, if my model had Property1, then my view returned a text box for Property1, when the form is submitted via the submit button, the mvc structure will automatically populate Property1 containing The text that was entered into the text box and passed this model to the action of the controllers.
Since I am dealing with a dynamic list of parameters that the user could check, I cannot write explicit logical properties in my model and explicitly create check boxes in my view. Given that my list is dynamic, I wonder if there are ways to create my model and see if the mvc structure can correctly fill in the model when submitting the form.
source
share