BindingSource Refresh

xprt picture xprt · Jul 18, 2009 · Viewed 21k times · Source

I have 2 classes i.e CustomerOrder and Customer class has a reference to a collection of orders. I use master detail BindingSources.

My problem is when I use the lazy load pattern for orders my detail BindingSource is not updated.

UI

BindingSource1.datasource = GetCustomers();
BindingSource2.DataMember = "Orders";
BindingSource2.datasource = BindingsSource1;

So in my datagridView1 Click event

if (customer.orders != null)
{
  customer.Orders = LoadOrders();
}

I appreciate any help with this.

Answer

Julien Poulin picture Julien Poulin · Jul 18, 2009

Try reseting the binding:

BindingSource1.DataSource = GetCustomers();
BindingSource2.DataMember = "Orders";

BindingSource2.DataSource = BindingSource1;
BindingSource2.ResetBindings(true);