Solved

2 DataGrids(parent/child) of a Relationel tables

Posted on 2004-10-08
12
380 Views
Last Modified: 2010-04-15
Hi,

I have 2 talbes in a DataSet, and made a DataRelation between the 2 tables in the DataSet.

One of the Tables are displayed in a datagrid, and when one of them is selected in the datagrid I want its childrows to be displayed in a second datagrid.

How can I get only the related data into the second datagrid, or maybe use a filter, to only get the child rows??

I totally blank on this one.

I use ByteFX to connect to a mysql database, but the same problem is there if MSSQL :-(

Here are my code:
private void Form1_Load(object sender, System.EventArgs e)
{
    MySqlConnection thisConnection = new MySqlConnection("Server=syska.dk; Username=root; Password=supermand; Database=c-sharp;");
   
    MySqlDataAdapter thisPollAdapter = new MySqlDataAdapter("SELECT * FROM poll", thisConnection);

    MySqlDataAdapter thisOptionAdapter = new MySqlDataAdapter("SELECT * FROM pollOption", thisConnection);

    thisPollAdapter.Fill(thisDataSet, "first");

    thisOptionAdapter.Fill(thisDataSet, "second");
   
    dataGrid.DataSource = thisDataSet.Tables["first"];

    DataRelation thisRelation = new DataRelation("thisRelation", thisDataSet.Tables[0].Columns["pollId"], thisDataSet.Tables[1].Columns["pollId"]);

    // MessageBox.Show( thisDataSet.Tables[1].ParentRelations. );

    // her skal de columns smides ind som passer til det ID som er valgt i det anden datagrid
    // dataGrid1.DataSource =
}

As you can see, I havent made anything fancy yet. Are this the right way to go, or are there are better way of doing this, I dont want to get all the data every time, I choose a new row in the first datagrid..

kind regards
Mikael Syska
0
Comment
Question by:syska
  • 6
  • 4
12 Comments
 
LVL 8

Expert Comment

by:gregasm
ID: 12260178
0
 
LVL 8

Expert Comment

by:gregasm
ID: 12260187
Do you have Yukon? It is still in Beta and probably should not be released into Production yet! haha..

But what are you trying to do?

1. Keep the data TOTALLY UP TO DATE AT ALL TIMES AT ALL COSTS.

2. Keep the data clean by IMPLEMENTING PESSIMISTIC or OPTIMISTIC CONCURRENCY.

"please advise.."
0
 
LVL 8

Expert Comment

by:gregasm
ID: 12260319
oops! sorry, that last posting I made at 9:07AM.. that was for a different question! hahaa DOH!
0
 

Author Comment

by:syska
ID: 12260636
gahhh, really that simple :-)

I had the question asked on microsoft news group and a other danish forum, no answer there for 2 days, and then u answer it in like NO TIME

Amazing :-P

A few more things:

how do I remove that + sign, to the left, where the relation name becomes visable, when I click at it?

How do I set the Column width? I can find to set the default width but not for each column?

think that will be all for now
0
 
LVL 8

Accepted Solution

by:
gregasm earned 125 total points
ID: 12260887
Would you mind opening another question for the follow up questions you asked above? Thanks. =]]
0
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 

Author Comment

by:syska
ID: 12260991
Will consider it, since I aint got so many points
0
 
LVL 8

Expert Comment

by:gregasm
ID: 12261553
How come you gave the answer a C grade?
0
 

Author Comment

by:syska
ID: 12263429
hmm, sorry :-/

Took the wrong one, It should have been A, but I must have taken the wrong one.

The solution was the first comment.

But just a little irritated that he would not answer the 2 other questions, that I had to his solution, but it he wont, I can't make him :-(

Will just have to wait until I get some more points :-P

thanks
0
 
LVL 8

Expert Comment

by:gregasm
ID: 12263611
I'll be happy to answer your other questions, but please try to look at this from our point of view. The individual questions (with the clear start and the clear end) are our incentive to reply and offer help. Without the incentive, then you'd have a newgroup, or a forum, and the questions would not be answered for a few days.

The points are an incentive for us to answer the questions quickly and completely as well. Otherwise, this would be no different than a newgroup or a forum, where the questions may not be answered for a while.

Thanks for your consideration =]]
0
 

Author Comment

by:syska
ID: 12263923
yahh, but still its very related questions to my question, its not like its about something completely different :-P
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Bit flags and bit flag manipulation is perhaps one of the most underrated strategies in programming, likely because most programmers developing in high-level languages rely too much on the high-level features, and forget about the low-level ones. Th…
Introduction This article series is supposed to shed some light on the use of IDisposable and objects that inherit from it. In essence, a more apt title for this article would be: using (IDisposable) {}. I’m just not sure how many people would ge…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now