Master-detail databinding with TypedList

Posts   
 
    
ity
User
Posts: 4
Joined: 10-Oct-2006
# Posted on: 10-Oct-2006 14:23:59   

I have created the classic Order-OrderItem master-detail WinForm. But because the database is heavyly normalized, displaying the OrderItem row involves joining many tables (plus expression fields), so I opted for a TypedList for the OrderItem rows. The OrderEntity exposes some collections (ProductCollection) as properties, and I extended it to expose OrderItemTypedList also as a property.

Now I have the chains: mOrderCollection <-> mOrderBindingSource <-> mOrderDataGridView, and mOrderCollection <-> mOrderBindingSource <-> mOrderItemBindingSource <-> mOrderItemDataGridView.

Now comes the problem. In the VS2005 designer I cannot see the OrderItemTypedList property to set the DataMember of the mOrderItemBindingSource. I do see the ProductCollection property. Any ideas why the TypedList doesn't show up? The Dataset gets away with it. Is there any difference (for binding) between the TypedList and a strongly typed DataTable?

Thanks.

Jessynoo avatar
Jessynoo
Support Team
Posts: 296
Joined: 19-Aug-2004
# Posted on: 10-Oct-2006 18:15:58   

Hi,

I think your problem is quite interesting so I'm investing about it.

Frans published an interesting article about complex binding which sounds like a good starting point.

http://weblogs.asp.net/fbouma/pages/115837.aspx

All this sounds like having to do with the binding interfaces. The DataMemberFieldEditor probably looks for something in your typedlist propertydescriptor that is missing. Setting the TypeContainedAttribute for the custom typedlist property as for the child collections didn't make the difference in my sandbox.

In the mean time, as you know, the DataMember property is expecting a string, so you might just handwrite your property's name. That should be fine.

Now I'll try to come out with more robust solution.

Cheers

ity
User
Posts: 4
Joined: 10-Oct-2006
# Posted on: 11-Oct-2006 09:32:34   

Thank you for your answer Jesse,

In the mean time, as you know, the DataMember property is expecting a string, so you might just handwrite your property's name.

I tried this already and only get a grid with the right number of rows but the rows are empty. Apparently the PropertyDescriptors don't know how to get the correct values from the TypedList. I had to make an object datasource of the OrderItemTypedList to be able to create the columns in the designer. On form load I initially fill the OrderEntityCollection and set up the mOrderItemBindingSource's DataSource and DataMember.

In the mean time I am handling the SelectionChanged event and and rebinding the binding source manually.

Cheers.

jaschag
User
Posts: 79
Joined: 19-Apr-2006
# Posted on: 11-Oct-2006 12:55:46   

ity wrote:

In the mean time I am handling the SelectionChanged event and and rebinding the binding source manually.

Something that I suspect you will keep having to do! Try databinding to a three level hierarchy without it...

ity
User
Posts: 4
Joined: 10-Oct-2006
# Posted on: 11-Oct-2006 13:40:46   

jaschag wrote:

Try databinding to a three level hierarchy without it...

What do you mean, the ralationship Customers-Orders-OrderItems or an inheritance hierarchy? With the first one I don't see any problems, with the DataSet I can do that.

jaschag
User
Posts: 79
Joined: 19-Apr-2006
# Posted on: 11-Oct-2006 15:55:22   

ity wrote:

jaschag wrote:

Try databinding to a three level hierarchy without it...

What do you mean, the ralationship Customers-Orders-OrderItems or an inheritance hierarchy? With the first one I don't see any problems, with the DataSet I can do that.

I was referring to binding to a 3 level object hierarchy - not datasets.