By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,660 Members | 1,735 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,660 IT Pros & Developers. It's quick & easy.

BindingSource: Change DataMember Assignment at Runtime?

P: n/a
In the Visual Studio 2005 designer, I have a grid, a binding source, and a
data set which contains two data tables.

In the Designer, I make the settings below. If I set the DataMember for the
binding source to Table1, I see the data in Table 1. If I set the DataMember
for the binding source to Table2, I see the data in Table 2. This all works
great.

I need to be able to reassign the DataMember for the binding source at
run-time. If I assign it to the same table that's set in the designer, I see
data. If I assign the DataMember to the other table, I don't see any data in
the grid.

Has anybody successfully switched DataMember assignments for a Binding
Source at run-time? If so, is there something like refresh that I'm missing?

Thanks,
Randy


myGrid.DataSource = myBindingSource.
myBindingSource.DataSource = myDataSet
myBindingSource.DataMember = myDataSet.Table1

**OR**

myBindingSource.DataMember = myDataSet.Table2

Nov 9 '07 #1
Share this Question
Share on Google+
1 Reply


P: n/a
I'll answer my own question. I'm using a third-party grid, and I needed to
use the following rebind command to refresh the binding between the grid and
the binding source after updating the binding source:

myGrid.Rebind(true);

Now I can switch between the data in either table at runtime.

Gee, I wonder if I can mark my own response as helpful...<ggg>

Randy

"randy1200" wrote:
In the Visual Studio 2005 designer, I have a grid, a binding source, and a
data set which contains two data tables.

In the Designer, I make the settings below. If I set the DataMember for the
binding source to Table1, I see the data in Table 1. If I set the DataMember
for the binding source to Table2, I see the data in Table 2. This all works
great.

I need to be able to reassign the DataMember for the binding source at
run-time. If I assign it to the same table that's set in the designer, I see
data. If I assign the DataMember to the other table, I don't see any data in
the grid.

Has anybody successfully switched DataMember assignments for a Binding
Source at run-time? If so, is there something like refresh that I'm missing?

Thanks,
Randy


myGrid.DataSource = myBindingSource.
myBindingSource.DataSource = myDataSet
myBindingSource.DataMember = myDataSet.Table1

**OR**

myBindingSource.DataMember = myDataSet.Table2
Nov 9 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.