I have created an user control which contains of a linklabel BO and combobox. Combobox would show records exist in BO using CopyDataFrom method.
I placed this user control on a maintenance form. I also placed the BO required on the form and add it to BOTranslations. I called myBO.FillAll() in Form_Load, and called a UserControl.method() to requery combobox. I can see all records shown in combobox (let say 100 records).
All the above are fine, except the following. I have code to show childform to add new record when user click on linklabel. My code will call BO.Add() and ChildFormDialog.ShowDialog(). During debugging, I found that, BO.Count in usercontrol is in adding state (Count = 101) but the Form.BO.Count is not (count is still 100). It caused my childform didnt enable boundcontrol and only show the first record.
Any ideas?
Thank you
As Ben mentioned in his previous post, using the SharedDataTable key would probably be a good approach for you here. It would just be a matter of creating a link label that either accepts a BusinessLayer object and possibly a SharedDataTable key property if this is going to change from time to time. By setting these properties on your control and knowing your constraints, you could create a common control to take advantage of the data sharing very easily.
I really don't know how to expand past that without knowing all of your needs and contraints, but I would start by creating an inherited LinkLabel and then adding the BO and SharedDataTableKey properties to your control to take advantage of this approach. In the constructor of the control, when not in design mode, you could then assign the SharedDataTableKey to the attached BO and programmatically set the binding values.