|
-
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
-
February 10th, 2010, 11:12 PM
#2
Re: Using single BindingNavigator with multiple data sources
Anyone displayed different tables on a single winform but on different tabs? Please tell me how...
Bhushan.
-
February 11th, 2010, 04:22 AM
#3
Re: Using single BindingNavigator with multiple data sources
 Originally Posted by bhushan1980
Can I do the above? Please let me know....
does it work?
win7 x86, VS 2008 & 2010, C++/CLI, C#, .NET 3.5 & 4.0, VB.NET, VBA... WPF is comming
remeber to give feedback  you think my response deserves recognition? perhaps you may want to click the Rate this post link/button and add to my reputation
private lessons are not an option so please don't ask for help in private, I won't replay
if you use Opera and you'd like to have the tab-button functionality for the texteditor take a look at my Opera Tab-UserScirpt; and if you know how to stop firefox from jumping to the next control when you hit tab let me know
-
February 11th, 2010, 06:47 AM
#4
Re: Using single BindingNavigator with multiple data sources
This just compiles...does not navigate the records in the 2nd and 3rd table on 2nd and 3rd tabs. The first tab works fine...Is there a way...? Has any one worked with them?
Thanks
Bhushan
-
February 11th, 2010, 08:47 AM
#5
Re: Using single BindingNavigator with multiple data sources
i need help in calculation of quantity with rate and want in output in amount i have inserted Label box as Quantity; Rate and Amount and Similar TextBox in 5 rows and then I need Total of Quantity and amount column wise. what coding should i do?
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
|