HighTechTalks DotNet Forums  

Simple DataRelation not working between 2 DataGridViews - Help

Dotnet Framework (WinForms DataBinding) microsoft.public.dotnet.framework.windowsforms.databinding


Discuss Simple DataRelation not working between 2 DataGridViews - Help in the Dotnet Framework (WinForms DataBinding) forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
Hexman
 
Posts: n/a

Default Simple DataRelation not working between 2 DataGridViews - Help - 04-27-2006 , 12:14 AM






Hi All,

I even started off with a new project and a blank form. In design
view I created a DataSet, 2 tables within the DataSet, 2
TableAdapters, and 2 BindingSources. One tableadapter and one
BindingSource for each table. The tables have the following key
structure:

Table1
PK t1Date
pk t1Part
pk t1WH
t1Cat
....other fields.....

Table2
PK t2ProdGrp
pk t2Cat
pk t2SubCat
....other fields.....

What I want to do is to scroll thru the items in Table1 and as a row
is selected to show only those rows in Table 2 with a matching
category (t1Cat = t2Cat).

Each row in Table1 has a t1Cat, there may be up to 50 or so Table2
matching Cat's. (We will manually be assigning sub-cats with this
app.)

In design view, I added a relation "PartsCats", parent key = t1Cat,
child key= t2Cat.

When I run the program, both DataGridViews get loaded and visible, but
no filtering of categories occurs in Table2. What am I missing?

I've seen some examples, but I can't see what I'm not doing. A little
help please.

Thanks,

Hexman

Reply With Quote
  #2  
Old   
RCD
 
Posts: n/a

Default Re: Simple DataRelation not working between 2 DataGridViews - Help - 04-28-2006 , 10:10 AM







Hi,

Try this:

binding1.DataMember = "table1"
binding1.DataSource = dataSet1
grd1.DataSource = binding1

binding2.DataMember = "PartsCats"
binding2.DataSource = binding1
grd2.DataSource = binding2

Regards

Ricardo

*** Sent via Developersdex http://www.developersdex.com ***

Reply With Quote
  #3  
Old   
Hexman
 
Posts: n/a

Default Re: Simple DataRelation not working between 2 DataGridViews - Help - 04-28-2006 , 11:07 PM



Ricardo,

Finally got it working thanks to you. I've been reading MS ADO.NET
2.0 Step by Step, the 2005 edition. Can't see where it talks about
setting up the databindings like you've shown here. Guess I'll have
to get an additional book. Do you have any recommendations?

THANK YOU,

Hexman

On Fri, 28 Apr 2006 08:10:15 -0700, RCD <nospam (AT) devdex (DOT) com> wrote:

Quote:
Hi,

Try this:

binding1.DataMember = "table1"
binding1.DataSource = dataSet1
grd1.DataSource = binding1

binding2.DataMember = "PartsCats"
binding2.DataSource = binding1
grd2.DataSource = binding2

Regards

Ricardo

*** Sent via Developersdex http://www.developersdex.com ***

Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.