Data Grid Data Binding

G

Guest

I've got a table called 'Apps' which relates to 'Decisions' in a zero to many relationship
I want to create a datagrid that shows a list of apps and all the decisions related to each one of them
The Datagrid would look something like
App AppDate Decision1 Decision2 Decision
1 30-MAR D A
2 29-MAR A -- --
3 29-MAR D D A
How can I do that?
 
W

William Ryan eMVP

Paulo:

I don't know what a Zero to many relationship is but if it's what it sounds
like, "there may be 0 parent records and many child records" then it sounds
like it violates the whole concept of keys. By definition, these would be
orphan records. Assuming you have a 1to many , you can use a DataRelation
object to bind the fields in the parent table to the child table
http://www.knowdotnet.com/articles/datarelation.html
Then you bind the dataset to the DataSet and you'll have both in there with
a + that will allow you to expand or collaps the parent records and see the
child ones (this is for the Winforms grid). You can modify the behavior by
setting the displaymember property but I think binding it to the dataset
will get you what you want.

However, if you have orphan records, you'll get an exception when you add
the datarelation b/c it violates the foreign key constraint. If you have
orphans, I'd recommend filtering them out and binding without them...then
have them in another table that you can display if someone needs them.

I may have misunderstood the problem and if so, please let me know and I'll
do what I can.

Cheers,

Bill;

Paulo said:
I've got a table called 'Apps' which relates to 'Decisions' in a zero to many relationship.
I want to create a datagrid that shows a list of apps and all the
decisions related to each one of them.
 

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