By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,098 Members | 1,895 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,098 IT Pros & Developers. It's quick & easy.

Master/Slave Relation

P: n/a
I can databind to a relation in WindowsForms for example:
I have a typed DataSet with an "Orders" table and a "Order Details"
table. They have a relation called "OrderRelation".

I have a ComboBox as master and DataGrid as slave:
OrdersAdapter.Fill(northwindDataSet1,"Orders");
OrderDetailsAdapter.Fill(northwindDataSet1,"Order Details");
comboBox1.DataSource = northwindDataSet1.Orders;
comboBox1.DisplayMember = "OrderID";
comboBox1.ValueMember = "OrderID";
dataGrid1.DataSource = northwindDataSet1.Orders;
dataGrid1.DataMember = "OrderRelation"; // Bound to relation

This works great when I select an item in the ComboBox the Detail rows
belonging to that item is displayed in the DataGrid.

However if I try to transfer this code to ASP.NET using a DropDownList
and a DataGrid:
OrdersAdapter.Fill(northwindDataSet1,"Orders");
OrderDetailsAdapter.Fill(northwindDataSet1,"Order Details");
comboOrder.DataSource = northwindDataSet1.Orders;
comboOrder.DataTextField = "OrderID";
comboOrder.DataValueField = "OrderID";
gridDetail.DataSource = northwindDataSet1.Orders;
gridDetail.DataMember = "OrderRelation";

The DataGrid always display all the detail rows?

I have also tried to move the DataBind call to the DropDownList
DataBinding event but with no luck
private void comboOrder_DataBinding(object sender, System.EventArgs e)
{
gridDetail.DataBind();
}

Nov 19 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.