Master Detail filter problem...

J

Jan Nielsen

Hi all
I have a problem with a master detail form that I can't find any solution to
(and I have already searched both the help files and the Internet)

I use Visual Studio 2002 and VB.Net

I have created a typed dataset with two tables (Person and Remarks) and a
master-detail relationship (PersonRemarks)
I have a form with textboxes showing the master row(s).
I have a datagrid showing the detail rows.

I bind the master textboxes like this:
Me.txtFirstname.DataBindings.Add(New System.Windows.Forms.Binding("Text",
Dataset.Persons.DefaultView, "ChristianName"))

(I use the .Defaultview because it makes sorting and filtering much easier.)

Now how do I bind the datagrid so it only shows the detail records?
I tried something like this
RemarksGrid.DataSource = DataSet
RemarksGrid.DataMember = "PersonRemarks"

But it wont work

Tia

Jan Nielsen
 
Y

yonggangwang

After you binding dataset to datagrid,
you need to use dataadapter to fill dataset,
dataadapter.fill(dataset)
 
J

Jan Nielsen

Hi,
Thanks for answering.

I have done that. The records are there.
But the details records are not in sync with the master record.

The problem is how to bind the datagrid to a datarelation, when I bind the
master records to the defaultview in stead of the table

Jan
 
Y

yonggangwang

I didn't use datarelation, I just create a dataset for detail table and a
select command for master table. After user change the value then wanted,you
can use the value as select condition,then select record from master and
detail . It must be woking.
 
G

GK

RemarksGrid.DataSource = DataSet.Tables("Person")
RemarksGrid.DataMember = "PersonRemarks"
 
G

GK

RemarksGrid.DataSource = DataSet.Tables("Person").DefaultView
RemarksGrid.DataMember = "PersonRemarks"
 
J

Jan Nielsen

He He.
Thank you sooo much.
It is so simple when someone else tell you
That really made my day (and it is only 9:30 am in Denmark)

Best regards

Jan
 
J

Jan Nielsen

Hi again
See GKs last answer. That is the correct solution
But thanks for your time

Jan
 

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