New Posts New Posts RSS Feed: populating and saving checklistbox data
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

populating and saving checklistbox data

 Post Reply Post Reply
Author
ShoshanahB View Drop Down
Newbie
Newbie
Avatar

Joined: 30-Mar-2008
Location: United States
Posts: 2
Post Options Post Options   Quote ShoshanahB Quote  Post ReplyReply Direct Link To This Post Topic: populating and saving checklistbox data
    Posted: 08-May-2008 at 3:46pm

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
 
 
 
 


Edited by ShoshanahB - 08-May-2008 at 3:46pm
Back to Top
davidklitzke View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 14-Jun-2007
Posts: 715
Post Options Post Options   Quote davidklitzke Quote  Post ReplyReply Direct Link To This Post Posted: 09-May-2008 at 9:24am

I am not sure than I completely understand the problem.  I think I understand the Business Object for luEthnicity but, I really don’t understand what you mean by the list of valid ethnicities for the person.  Isn’t this just any one of the instances of the luEthnicity?  However, it seems like you may be suggesting that a person could belong to more than one Ethnicity.  This is fine, but while I may belong to Ethnicity A and E, Ethnicity A may be incompatible with Ethnicity B and I may belong to either Ethnicity A or Ethnicity B, but not both.

 

I’d also like to know how you are storing this information in the database.  For example does each Person object have a child collection of Assigned-Ethnicitiy objects.  Each Assigned-Ethnicity object has a foreign key reference to Person and a foreign key reference to Ethnicity.

 

Maybe an example would help,

Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down