المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : Problem to display Master-Details rows.



C# Programming
04-28-2009, 05:05 PM
i have 2 tables named : Customers, Orders which have relation together (Customers table is Parent table).
Now in my form, i have 2 DataGridView which display list of customers (in dataGridView1) and list of orders of selected customers (in dataGridView).
i wrote this code, but at runTime all orders display to dataGridView2 and when i change customer record, nothing happend!
here is my code :


TestDataSet ds = new TestDataSet();
private void Form2_Load(object sender, EventArgs e)
{
TestDataSetTableAdapters.CustomersTableAdapter cA = new TestDataSetTableAdapters.CustomersTableAdapter();
cA.FillCustomers(ds.Customers);

TestDataSetTableAdapters.OrdersTableAdapter oA = new TransactionalUpdate.TestDataSetTableAdapters.OrdersTableAdapter();
oA.FillOrders(ds.Orders);

dataGridView1.DataSource = ds.Customers.DefaultView;

dataGridView2.DataMember = ds.Orders.ParentRelations[0].RelationName;
dataGridView2.DataSource = ds.Orders.DefaultView;
}

can anybody help me to solve this problem ?
Thanks