|
I am new to both DevForce and Winforms, and am stumped on what seems like a fairly simple operation.
I have a checklistbox control that needs to display a set of Ethnicities, with the valid ethnicities for the selected person. The ethnicities available are stored in a business object called luEthnicity, and the list of valid ethnicities for the person is stored in another business object called buPerson_Ethnicity_Assignments.
I have created and populated two BindingSource objects to handle the business objects (bsEthnicities and bsAssignedEthnicities respectively).
I found that it is simple to display the available items by setting the checkboxlist's DataSource to bsEthnicities, and then identifying the DisplayMember and ValueMember.
Based on my google searches, it looks like I must manually populate and save the checkboxlist's selected values.
Before I start building a tool for this, I wanted to see if a) there is a cool tool or code example for these processes, and b) confirm that my general approach will work in the DevForce object model.
Here's what I think is needed:
- On Page Load, loop through each buPerson_Ethnicity_Assignment for the selected person. For each assigned ethnicity, use the SetItemChecked function to check the corresponding value in the checkboxlist.
-
- When saving the page, loop through each checked item in the checkboxlist, and insert a new record into bsAssignedEthnicities for any newly selected ethnicities.
Some questions:
1. Is there an easier way? This seems like such a common activity, I'm suprised there isn't a code block somewhere. Perhaps I've become spoiled by the DevForce binding managers. :)
2. When adding new assigned records, do I insert into the bsAssignedEthnicities, or add directly to the buPerson_Ethnicity_Assignments object? If I go direct, could you direct me to a tutorial or documentation on how to do this?
thanks in advance for you help,
~ Shanah
|