Is there a way to bind a grid to multiple business objects?
I have a parent class that has a one to one relationship with it's child. Currently I have 2 grids(one per class bound) but would like to have one grid with a coupla bands.
ParentClass has many fields but 3 fields I need readonly to display in the ChildClassGrid so it would look like
ParentGrid
ParentClassField1 ParentClassField2 ParentClassField3 ParentClassField4
For each Row in the ParentClass The ChildGrid would be
ReadOnlyParentClassField1 ReadOnlyParentClassField2 ReadOnlyParentClassField3 ChildClassField1 ChildClassField2
ParentClass & ChildClass are bound to different BusinessObjects Binding
I currently have three unbound columns in the ChildGrid but am unsure how to fill the columns
in the initRow I do
e.Row.Cells("ReadOnlyParentClassField1").Value = "ReadOnlyParentClassField1" but am unsure how to link them to its parents values
Regards
_Eric
Eric,
We do this quite a lot for displaying data. What we do is create a 'hierarchical' parent which derives from your parent object to which we add an additonal bindinglist containing the child objects. We then create a returm this 'hierachical parent as a binding list and set this to the datasouirce of the grid. The data should then be displayed hieararchically. We've done this down to about 6 levels of 'nesting' so far andworks far better than having multiple grids.
Jim
I'm having a little trouble following exactly what your data structure is.
The simple answer to your question is no, you cannot bind the grid to more than one data source. So one thing you could do is build a single data source that contains all of the data in a hierarchy.
You might also want to consider using the UltraWinTree instead of UltraWinGrid. The tree has the ability to bind each rows collection individally.
Or, you might be able to acheive what you want with unbound columns, but it's hard for me to say, because as I said, I am really not following your description very well.