PC Review


Reply
Thread Tools Rate Thread

DataGridView BindingSource Master Child conundrum

 
 
John Rivers
Guest
Posts: n/a
 
      14th May 2010
this should be a simple bit of code:

// Build DataSet
dataset.Tables.Add(tblMaster);
dataset.Tables.Add(tblChild);
dataset.Relations.Add(tblMaster.Columns["DelSchedID"],
tblChild.Columns["DelSchedID"]);

// Build Master BindingSource
srcMaster.DataSource = dataset;
srcMaster.DataMember = "Master";

// Build Child BindingSource
srcChild.DataSource = dataset;
srcChild.DataMember = "Child";

// Bind Controls
gridMaster.DataSource = srcMaster;
gridChild.DataSource = srcChild;

it all works *except* the gridChild isn't filtered

any ideas?
 
Reply With Quote
 
 
 
 
John Rivers
Guest
Posts: n/a
 
      14th May 2010
Solution was easy
the child BindingSource.DataSource should be set to the master
bindingsource (not to the dataset)
and the child BindingSource.DataMember should be set to the name of
the DataRelation

>
> // Build DataSet
> dataset.Tables.Add(tblMaster);
> dataset.Tables.Add(tblChild);
> dataset.Relations.Add("RELATION", tblMaster.Columns["DelSchedID"], // <<<<<<
> tblChild.Columns["DelSchedID"]);
>
> // Build Master BindingSource
> srcMaster.DataSource = dataset;
> srcMaster.DataMember = "Master";
>
> // Build Child BindingSource
> srcChild.DataSource = srcMaster; // <<<<
> srcChild.DataMember = "RELATION"; // <<<<
>
> // Bind Controls
> gridMaster.DataSource = srcMaster;
> gridChild.DataSource = srcChild;
>

 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
DataTable, BindingSource and DataGridView Eric B. Microsoft C# .NET 2 20th Nov 2008 07:03 PM
DataGridView - BindingSource Help Needed Tom Microsoft C# .NET 3 4th Dec 2007 08:55 PM
Bind DataGridView with BindingSource with .net 2.0 Mike Microsoft C# .NET 7 19th Jun 2007 10:06 PM
Problem with DataGridView and BindingSource shibeta@wp.pl Microsoft C# .NET 4 2nd Feb 2007 01:54 PM
DataGridView Master-Detail (Parent-Child) Mark Tompkins Microsoft ADO .NET 2 17th Jun 2006 12:41 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:45 AM.