473,322 Members | 1,846 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

Tie one grid to another (master/detail)

Hey All,

Working with the .Net data has been the hardest part of my
transition. It just doesn't seem very intuitive.

I want to have a master/detail relationship between 2 grids. When the
user navigates grid 1, only the details for that record appear in grid
2. How?

I created a datasource and added the 2 tables. The relationship
between the two tables was created. Now what? How do I get the first
grid to act like a filter for the second grid?

I am using devexpress grids so hopefully this isn't grid specific.

TIA

~GINA_M~

Jun 16 '07 #1
3 2941
I usually use DataGridView in very rare cases when all that's needed is to
display some single table. Anything more complicated than that, and this
control falls out of the question.

For your task I'd use a pare of regular ListView controls, which I'd
populate programmatically.

SqlConnection connection = new SqlConnection( connectionString );
connection.Open();

SqlCommand cmd1 = new SqlCommand( "select * from table1", connection );
SqlDataReader reader = cmd1.ExecuteReader();

while( reader.Read() )
{
// add rows to ListView1:
ListViewItem item = listView1.Items.Add( (int)reader[0] ); // Say, some
record ID
item.Subitems.Add( (string)reader[1] ); // record description
}

reader.Close();

// Now handle the selection change in ListView1 and populate ListView2:
void listView1_SelectionChanged( ... ) // or whatever the event's name
{
SqlCommand cmd2 = new SqlCommand( "select * from table2 where ID = " +
listView1.SelectedItems[0].Text, connection );
reader = cmd2.ExecuteReader();

while( reader.Read() )
{
// add rows to ListView2:
ListViewItem item = listView2.Items.Add( (int)reader[0] ); // some
record ID
item.Subitems.Add( (string)reader[1] ); // record description
}
reader.Close();
}

// On application exit:
connection.Close();

"Gina_Marano" <gi*******@gmail.comwrote in message
news:11**********************@x35g2000prf.googlegr oups.com...
Hey All,

Working with the .Net data has been the hardest part of my
transition. It just doesn't seem very intuitive.

I want to have a master/detail relationship between 2 grids. When the
user navigates grid 1, only the details for that record appear in grid
2. How?

I created a datasource and added the 2 tables. The relationship
between the two tables was created. Now what? How do I get the first
grid to act like a filter for the second grid?

I am using devexpress grids so hopefully this isn't grid specific.

TIA

~GINA_M~

Jun 16 '07 #2
Hello Gina_Marano,

See there http://www.syncfusion.com/FAQ/winfor...44c.aspx#q780q

---
WBR, Michael Nemtsev [.NET/C# MVP].
My blog: http://spaces.live.com/laflour
Team blog: http://devkids.blogspot.com/

"The greatest danger for most of us is not that our aim is too high and we
miss it, but that it is too low and we reach it" (c) Michelangelo

GHey All,
G>
GWorking with the .Net data has been the hardest part of my
Gtransition. It just doesn't seem very intuitive.
G>
GI want to have a master/detail relationship between 2 grids. When the
Guser navigates grid 1, only the details for that record appear in
Ggrid 2. How?
G>
GI created a datasource and added the 2 tables. The relationship
Gbetween the two tables was created. Now what? How do I get the first
Ggrid to act like a filter for the second grid?
G>
GI am using devexpress grids so hopefully this isn't grid specific.
G>
GTIA
G>
G~GINA_M~
G>
Jun 16 '07 #3
Thanks Guys for giving it a try. I will look into Ashot's solution.

~Gina_M~

Jun 25 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: bastos.sergio | last post by:
Hello everyone, I'm having a bit of a problem seeying the big picture in this and I was hoping somebody more experienced in this could help tell me if I'm proceding right. I plan to construct a...
8
by: Christopher Weaver | last post by:
I'm having the hardest time doing the simplest thing. I have a DataGrid bound to a table in a master detail DataRelation within a DataSet relTaskActivities = new DataRelation("TaskActivities",...
12
by: Gary Brower | last post by:
Hi, I am using VB.Net to create an ASP web form. My goal is to create a master/detail web form that allows users to create new master and detail records. For example the form would have header...
0
by: hlam | last post by:
Help - Calculating the total of a column in a data grid -- when data grid is part of Master-Detail set-up I have setup a Master-Detail form using Visual Studio.Net. A ListBox is the (Master)...
7
by: erniej | last post by:
as per instructions in the walkthrough, I have managed to create a master/detail relationship between two datagrids. However I have a requirement to apply this to three datagrids and the third...
2
by: Ken C | last post by:
I've setup a Master detail table from a typed dataset on 2 different data grid The first one I bind it with the Master data table name The second data set I bind it with the MasterDetail...
2
by: Coen | last post by:
Hello, I have a strange performance delay of about 2 sec's in moving to the next row. I use multiple forms with each master-detail table relations. The master-table displays it's table rows in...
4
by: =?Utf-8?B?Si5NYXR0aGV3cw==?= | last post by:
Picture the cut down scenario... Say I have three datatables (Person, Address, Street) that are linked with datarelation objects using the PK/FK associations... Person -------- PersonId {PK}...
0
by: Mike Wilson | last post by:
Dear group, I have an invoice entry form, which is a simple Master fields / Detail grid. The main summary information of the invoice are stored in one table in a dataset, which is bound using a...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.