Mr_Fulano
asked on
Problem: 2 BindingSources, 1 DataTable
Hi, I'm using VB 2005, WinForms. I have DataGridView on one of my Forms. I use a BindingSource to supply data to the DataGridView as shown in the code below:
Public bs As New BindingSource '< Declared at the top of my Form.
In the LOAD event I state:
bs.DataSource = Me.dtTable1
DataGridView1.DataSource = bs
All that works fine...
I also have an RDLC report that I display using ReportViewer. I created a BindingSource for that report, because I wanted to filter the data in a different way than in the other BindingSource, so I declared it in my Button_Clicked event as shown below:
Dim bsReport As New BindingSource
bsReport.DataSource = Me.dtTable1
bsReport.Filter = "ProductID = 67"
Although this give me the correct results for my report, it re-filters my DataGridView1 to show only products with ProductID = 67. (Not what I wanted)
I know that both BindingSources are fed by the same DataTable (dtTable1), but why is one BindingSource affecting the other if I'm using "NEW" to declare the second BS? And equally as important, how can I avoid this and still be able to use the Filter option in BS to get the data I need in my report?
Thanks,
Fulano
Public bs As New BindingSource '< Declared at the top of my Form.
In the LOAD event I state:
bs.DataSource = Me.dtTable1
DataGridView1.DataSource = bs
All that works fine...
I also have an RDLC report that I display using ReportViewer. I created a BindingSource for that report, because I wanted to filter the data in a different way than in the other BindingSource, so I declared it in my Button_Clicked event as shown below:
Dim bsReport As New BindingSource
bsReport.DataSource = Me.dtTable1
bsReport.Filter = "ProductID = 67"
Although this give me the correct results for my report, it re-filters my DataGridView1 to show only products with ProductID = 67. (Not what I wanted)
I know that both BindingSources are fed by the same DataTable (dtTable1), but why is one BindingSource affecting the other if I'm using "NEW" to declare the second BS? And equally as important, how can I avoid this and still be able to use the Filter option in BS to get the data I need in my report?
Thanks,
Fulano
ASKER
Hi Game-Master...yes, I agree. I'm hoping someone will have a solution for allowing 3 BS to work with 1 DT.
Thanks,
Fulano
Thanks,
Fulano
ASKER
...correction >> for allowing (TWO) 2 BS...not 3. Sorry for the typo.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
That worked thank!
i think the reason is that ur working on the same dataTable
even though ur using different binding source...
game-master