471,071 Members | 1,209 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

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

Updating a second DataGridView with Access Data

I have a form with two DataGridView controls. The form has linked to it an
Access database with just two tables. The second table contains unique
"child" data having a one-to-one relationship with each row of the first
table. I am able to display the first table's data in one of the
DataGridView controls - DatgaGridView_A.

What I want to do, but don't know how, is to select a row from the
DataGridView_A and have the data associated with it from the second table
displayed in DataGridView_B. Can someone show me how this is done or give me
an example?
--
-----------
Thanks,
Steve
Apr 8 '06 #1
4 1884
This is how I did it in a WEB application, gdCustomers is the main grid,
dgOrders is the detail grid.
Once a selected row is clicked in the Customers grid the detail grid is
filled with the orders.

private void dgCustomers_SelectedIndexChanged(object sender,
System.EventArgs e)

{

DataGridItem item ;

item = dgCustomers.Items[dgCustomers.SelectedIndex];

string mySql = "Select * from Orders Where CustomerID = '" +
item.Cells[1].Text + "'";

SqlCommand comOrdrs = conn.CreateCommand();

comOrdrs.CommandText = mySql;

comOrdrs.CommandType = CommandType.Text;

SqlDataAdapter daOrders = new SqlDataAdapter(comOrdrs);

DataSet dsOrders = new DataSet();

daOrders.Fill(dsOrders);

dgOrders.DataSource = dsOrders;

dgOrders.DataBind();

}
"Steve Teeples" <St****@newsgroups.nospam> wrote in message
news:42**********************************@microsof t.com...
I have a form with two DataGridView controls. The form has linked to it an
Access database with just two tables. The second table contains unique
"child" data having a one-to-one relationship with each row of the first
table. I am able to display the first table's data in one of the
DataGridView controls - DatgaGridView_A.

What I want to do, but don't know how, is to select a row from the
DataGridView_A and have the data associated with it from the second table
displayed in DataGridView_B. Can someone show me how this is done or give
me
an example?
--
-----------
Thanks,
Steve

Apr 8 '06 #2
What is "conn"?
--
-----------
Thanks,
Steve
"Doru Roman" wrote:
This is how I did it in a WEB application, gdCustomers is the main grid,
dgOrders is the detail grid.
Once a selected row is clicked in the Customers grid the detail grid is
filled with the orders.

private void dgCustomers_SelectedIndexChanged(object sender,
System.EventArgs e)

{

DataGridItem item ;

item = dgCustomers.Items[dgCustomers.SelectedIndex];

string mySql = "Select * from Orders Where CustomerID = '" +
item.Cells[1].Text + "'";

SqlCommand comOrdrs = conn.CreateCommand();

comOrdrs.CommandText = mySql;

comOrdrs.CommandType = CommandType.Text;

SqlDataAdapter daOrders = new SqlDataAdapter(comOrdrs);

DataSet dsOrders = new DataSet();

daOrders.Fill(dsOrders);

dgOrders.DataSource = dsOrders;

dgOrders.DataBind();

}
"Steve Teeples" <St****@newsgroups.nospam> wrote in message
news:42**********************************@microsof t.com...
I have a form with two DataGridView controls. The form has linked to it an
Access database with just two tables. The second table contains unique
"child" data having a one-to-one relationship with each row of the first
table. I am able to display the first table's data in one of the
DataGridView controls - DatgaGridView_A.

What I want to do, but don't know how, is to select a row from the
DataGridView_A and have the data associated with it from the second table
displayed in DataGridView_B. Can someone show me how this is done or give
me
an example?
--
-----------
Thanks,
Steve


Apr 10 '06 #3
conn is the connection instance
SQLConnection con = new SQLConnection(....)
"Steve Teeples" <St****@newsgroups.nospam> wrote in message
news:B1**********************************@microsof t.com...
What is "conn"?
--
-----------
Thanks,
Steve
"Doru Roman" wrote:
This is how I did it in a WEB application, gdCustomers is the main grid,
dgOrders is the detail grid.
Once a selected row is clicked in the Customers grid the detail grid is
filled with the orders.

private void dgCustomers_SelectedIndexChanged(object sender,
System.EventArgs e)

{

DataGridItem item ;

item = dgCustomers.Items[dgCustomers.SelectedIndex];

string mySql = "Select * from Orders Where CustomerID = '" +
item.Cells[1].Text + "'";

SqlCommand comOrdrs = conn.CreateCommand();

comOrdrs.CommandText = mySql;

comOrdrs.CommandType = CommandType.Text;

SqlDataAdapter daOrders = new SqlDataAdapter(comOrdrs);

DataSet dsOrders = new DataSet();

daOrders.Fill(dsOrders);

dgOrders.DataSource = dsOrders;

dgOrders.DataBind();

}
"Steve Teeples" <St****@newsgroups.nospam> wrote in message
news:42**********************************@microsof t.com...
>I have a form with two DataGridView controls. The form has linked to it
>an
> Access database with just two tables. The second table contains unique
> "child" data having a one-to-one relationship with each row of the
> first
> table. I am able to display the first table's data in one of the
> DataGridView controls - DatgaGridView_A.
>
> What I want to do, but don't know how, is to select a row from the
> DataGridView_A and have the data associated with it from the second
> table
> displayed in DataGridView_B. Can someone show me how this is done or
> give
> me
> an example?
> --
> -----------
> Thanks,
> Steve


Apr 10 '06 #4
Thank you for the direction. My issue is now resolved.
--
-----------
Thanks,
Steve
"Doru Roman" wrote:
conn is the connection instance
SQLConnection con = new SQLConnection(....)
"Steve Teeples" <St****@newsgroups.nospam> wrote in message
news:B1**********************************@microsof t.com...
What is "conn"?
--
-----------
Thanks,
Steve
"Doru Roman" wrote:
This is how I did it in a WEB application, gdCustomers is the main grid,
dgOrders is the detail grid.
Once a selected row is clicked in the Customers grid the detail grid is
filled with the orders.

private void dgCustomers_SelectedIndexChanged(object sender,
System.EventArgs e)

{

DataGridItem item ;

item = dgCustomers.Items[dgCustomers.SelectedIndex];

string mySql = "Select * from Orders Where CustomerID = '" +
item.Cells[1].Text + "'";

SqlCommand comOrdrs = conn.CreateCommand();

comOrdrs.CommandText = mySql;

comOrdrs.CommandType = CommandType.Text;

SqlDataAdapter daOrders = new SqlDataAdapter(comOrdrs);

DataSet dsOrders = new DataSet();

daOrders.Fill(dsOrders);

dgOrders.DataSource = dsOrders;

dgOrders.DataBind();

}
"Steve Teeples" <St****@newsgroups.nospam> wrote in message
news:42**********************************@microsof t.com...
>I have a form with two DataGridView controls. The form has linked to it
>an
> Access database with just two tables. The second table contains unique
> "child" data having a one-to-one relationship with each row of the
> first
> table. I am able to display the first table's data in one of the
> DataGridView controls - DatgaGridView_A.
>
> What I want to do, but don't know how, is to select a row from the
> DataGridView_A and have the data associated with it from the second
> table
> displayed in DataGridView_B. Can someone show me how this is done or
> give
> me
> an example?
> --
> -----------
> Thanks,
> Steve


Apr 10 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by weird0 | last post: by
reply views Thread by leo001 | last post: by

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.