|
-
February 10th, 2010, 02:00 PM
#1
Using single BindingNavigator with multiple data sources
Hi,
I have a database with 6 tables 3 are main course tables and other 3 have a relationship with a single table out of the 3 main tables. I have created a 3-tier app, in which I have created respective typed table adapters and typed datasets in the data access layer, respective classes and objects that map with data access layer in the business logic layer and a winforms UI that shows each of the 3 main tables' data in separate tabs. The three related tables' data is shown on the main course table. Thus each tab shows data from 2 tables, one main course and the other that is related to it. I am binding the UI controls to the business objects. There is one binding navigator and I want it change its 'binding source' depending on the tab selected. I know I can create separate binding navigators and then hide and show them depending on what tab is activated; but I do not want to do that. Is there a way to achieve this safely and without going in to much of coding? What I was thinking was to just assign null to navigator's binding source and then reallocate the new binding source in tab change event...some thing of this sort:
Code:
public void OnTab1()
{
tab1BdSrc.DataSource = BLL.MyBizObj1.GetBOData1(); // Get complete data for both tables
tab1RelBdSrc.DataSource = tab1BdSrc; // Retrieve the related rows only
tab1RelBdSrc.DataMember = "tab1RelBdSrcobject member inside tab1BdSrc";
if (tabCommonBdNavig.BindingSource != null)
tabCommonBdNavig.BindingSource = null;
tabCommonBdNavig.BindingSource = tab1BdSrc;
}
public void OnTab2()
{
tab2BdSrc.DataSource = BLL.MyBizObj2.GetBOData2(); // Get complete data for both tables
tab2RelBdSrc.DataSource = tab2BdSrc; // Retrieve the related rows only
tab2RelBdSrc.DataMember = "tab2RelBdSrcobject member inside tab2BdSrc";
if (tabCommonBdNavig.BindingSource != null)
tabCommonBdNavig.BindingSource = null;
tabCommonBdNavig.BindingSource = tab2BdSrc;
}
public void OnTab3()
{
tab3BdSrc.DataSource = BLL.MyBizObj3.GetBOData3(); // Get complete data for both tables
tab3RelBdSrc.DataSource = tab3BdSrc; // Retrieve the related rows only
tab3RelBdSrc.DataMember = "tab3RelBdSrcobject member inside tab3BdSrc";
if (tabCommonBdNavig.BindingSource != null)
tabCommonBdNavig.BindingSource = null;
tabCommonBdNavig.BindingSource = tab3BdSrc;
}
Can I do the above? Please let me know....
On brief look up I did not find anything that needs to be called before and after changing the bind navigator's binding source. So I just set the reference to other binding sources. Is it necessary to call update, invalidate, refresh methods on the navigator?
Thanks for reading through...
Bhushan
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|