StrataFrame Forum

Main form, user controls, business objects and databinding direction

http://forum.strataframe.net/Topic14142.aspx

By fansanitis - 2/6/2008

I have an evaluation application that has basically 4 tables.  The Evaluaions table containing the demographics, a Questions table containing the question nbr and text, an Answers table containing the possible answers for each question (e.g. Always, sometimes, Never) and a Responses table with row for each question's response.  There are multiple Questions for each Evaluations. Multiple Answers for each Question and a single Response for each Question.  Since the display of the Questions/Answers all have the same layout I created a user control which contains labels controls for the question nbr and text and a radiobuttongroup for the responses.  I added the Questions and Answers BOs to the user control created a Load method that accepts the question nbr, fills the BOs by question nbr and then updates the Text property of the controls with the data from the BOs.  Everything displays just fine.

Now I need to add logic to bind the selected answers to a Responses BO.  Where should this BO reside?  On the main form?  If so how is it bound to the selected response in the user control?  Is this where the BusinessObjectTranslator comes into play?  I didn't see much about it in the Help file.  Do I need an instance of the Responses BO on both the main form and the user control?

Any direction would be appreciated!! 

By Trent L. Taylor - 2/6/2008

Well, you will probably want to actually put the BO on both the form and the user control....and then use the BOTranslations property on the user control once it is dropped on the form.  This way you can bind all of the controls within the user control to the BO dropped on the user control, but when you drop it on the form, you will be able to populate your BOs on the form BO and then the translation will "translate" the BOs that sit on the user control into the actual BOs on the form.  So yes, go ahead and drop the Question and Answer BOs on the user control...and if the form on which this control is dropped needs to actually be the location where the data is loaded and updated, then go to the BOTranslations property on your user control once it is dropped on the form and setup a BO translation...this way all of your loading and save logic can actually be done through the BOs on the form rather than the user control...if in fact that is what you are trying to accomplish.