PDA

View Full Version : Bidirectional data binding with lists and other rich control


Ted Husted
05-09-2005, 06:11 PM
The example on the wiki only shows TextBoxes.

* http://opensource.atlassian.com/confluence/spring/display/NET/Bidirectional+data+binding

Is anyone using bidirectional data binding with lists and other rich controls?

Right now, we're looping through the control collection and setting/getting the controls with an IDictionary by matching the entry key with the control ID. In the case of lists, there's special logic that matchs a control suffixed "_list" with another IDictionary entry without the suffix for both sets and gets. So the DataSource would be set to the "county_list" entry, and then the Selected item set would be set to the value of the "country" entry (if any). The result is the list controls are automatically defaulted to the current value, and the current value is automatically updated on a postback.

Is there a technique for automatically defaulting and harvesting the selected value for lists and other rich controls?

-Ted.

Aleks Seovic
05-15-2005, 05:42 PM
Ted,

You can use standard .Net data binding (or your custom logic) to populate list. Spring data binding can then be used to automatically bind SelectedItem property to your data model.

- Aleks