Master/Child Binding not working

  • Thread starter Flomo Togba Kwele
  • Start date
F

Flomo Togba Kwele

I have created a dataset containing master/detail tables and used it as
a datasource for a master BindingSource. I created another BindingSource
for the detail table - its datasource is the master BindingSource and
its DataMember is the relationship between the 2 tables.

I laid out 2 DataGridViews. The first grid is bound to the master
bindingsource and the second is bound the the detail bindingsource.
Navigation works just fine. When clicking on the parent rows, the
associated child rows appear in the child grid.

Now I want to break out the columns in the detail rows into individual
controls - textboxes and comboboxes. I set the databindings of the
individual controls to the detail bindingsource and its associated
datamember. When I click on the child rows of the child grid, nothing
appears in the individual controls.

What am I missing here? I've struggled with this problem for quite a
while.

Thanks, Flomo
 
W

WenYuan Wang

Hi Flomo,

According to your description, I created an winform application on my
machine follow the steps as below. Everything is fine. Would you please
confirm this and let me know if there is anything different from your
scenario?

I assume you are developing Winform Application against Visual Studio
2005. You have created a Strongly Typed DataSet both for Master datatable
and Detailed datatable, also added the relation to connect these two
tables. Now there are Four controls on your form in design mode. They are
One Master DataGridView, One Detailed DataGridView, One TextBox and One
ComboBox.

With Master Bindingsource
Datasource is Typed Dataset.
Datamember is Master Table

With Detailed Bindingsource
Datasource is Master Bindingsource
Datamember is the relationship between Master Table and Detailed Table.

TextBox is databinding to the related column of Detailed Bindingsource.
For example: Detailedbindingsource -c1

ComboBox is databinding to another related column of Detailed Bindingsource.
For example: Detailedbindingsource -c2

Master Binding Source and Detailed Bindingsource work fine for you. But
TextBox and ComboBox don't change when you select different rows in the
Detailed DataGridView.
(Does the value of TextBox and ComboBox always point to the first row in
the child table?)

On my machine, each individual control will represent the value according
the row in Detailed DataView.

I suggest you may check whether you have set any property (such as
Datasoure) of the Combobox.

Hope this helps,
Sincerely,
Wen Yuan
 
F

Flomo Togba Kwele

Wen,

Yes, the child textboxes and combos all point to the first row, no
matter which row of the child grid I click on.

Can you send me your solution? Thanks, Flomo.
 
F

Flomo Togba Kwele

Sorry, Wen, my mistake. I wired the child grid to the master
bindingsource rather than the detail bindingsource. It works now. Thanks
for the push.
 
W

WenYuan Wang

I'm so glad to hear you have resolved the issue by yourself.
Thanks for your reply, Flomo.
Please feel free to let me know if you have any further issue.:)

Have a great day.
Sincerely,
Wen Yuan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top