I have a winforms app that uses a grid and can bind to a typed dataset and shows the hierachy just fine,
When I make a similar sample and set the grid datasource to the main entity framework object I get a redundant recursive hierachy starting at the connection.
If I set the datasource to the top level entity table, I see the proper hierarchy in the "add new" button and see the rows for this top level parent table but there are no child rows if I click the + sign on the parent row.
Using datasource binding and the UltraDataSource shows the proper hierachy in the "add new" button diagram but show no data at all and I can debug the entity tables and the data is present.
Any suggestions?
Thanks, Dave
Hi Mike,
It's a hard one for me to explain but I think you've got it. Basically I'm being given data via an object model which I'm putting into BindingLists. The problem is that although the data in Grid 1 and Grid 2 is the same at a given point in the hiearchies:
Grid 1 -> B->A1->A2 etc
Grid 2 -> A1->A2
the objects are different objects (checked with object.ReferenceEquals). So adding a new child item to A1 in Grid 2 won't be reflected in Grid 1. I'm thinking that I need to ensure that the data is mapped to an object only once. So then if A1 is the one and only A1 instance the changes should be reflected in both grids. I could be completely wrong though but off to do some more testing now.
Thanks for your reponses to date. They're helping me to clarify how the Binding is working.
Note for anyone reading: this is not an .NET Entity Data Model issue as my code is not using it.
Regards,
Martin
I just went back and re-read your first post.
So you have an object "A" which has a property of BindingList<A>.
And you also have an object "B" which has a property of BindingList<A>.
You bind one grid to a BindingList<A> and another grid to a BindingList<B>.
Is that right?
So then you add a child row to the first grid and... that's where you lose me. How would this have any effect on the second grid? Any given "A" object in the root band of Grid 1 has it's own BindingList<A> which contains it's children. So adding an item to that BindingList cannot possibly have any effect on any child row of a B object. Unless your BindingList<A> property is settable and you are assigning the same collection to two different parents.
If that's the case, then my advise would be not to do that. Using the same object and binding it to two different BindingLists is dangerous and probably won't work right.
Hi Martin,
Okay. I'm still a bit confused, though.
I think there might be a typo here:
Grid 1 bound to (BindingList<A>) containing Children of BindingList<A>
Grid 2 bound to (BindingList<B>) containing Children of BindingList<A>
Is that first line correct? Both parents and children are "A" objects?
Anyway... none of these lists have any connection to each other as far as I can see here. So adding a child row to any of these lists will have no effect on any other list. That has nothing to do with the grid, though. The grid won't show a new item because no new item exists.
Sorry for the confusion Mike.
The "Views" are actually WinGrids. View is my term for items in my apps presentation layer. Bascially I have Grid 1 bound to one BindingList and Grid 2 bound to the other. So it would look like this
After some reading I think because the grids are technically bound to different BindingSources there is no way for the children that are common in both hierarchies to notify other BindingSources that something has changed.
I hope that makes things clearer. Hopefully someone can shed some light on this.
I don't understand your question. What do you mean by "View"? Is that an EntityFramework thing? What does it have to do with the WinGrid?