I have a collection of checkboxes that are created on the fly based on information from a database. If any of the checkboxes are checked, a corresponding div opens up containing textboxes which can be filled in. I need to then record the information from only the textboxes which have corresponding checkboxes that are checked. How would I go about binding only the information that has a parent checkbox checked? BTW: All of the information is part of a larger complex object.
Share
Conditionally binding like this isn’t really feasible. Instead do this:
Create a different set of properties or create an object for each section, then when the form is posted to the server check the values of the check boxes and pull the necessary data from the appropriate fields, ignoring the others.
For example, lets say you have two sections, one with a “Name” field, and the other with an “Address” field. Check to see if the Name checkbox is checked, and if it is, get the value of “Name”, otherwise ignore it.