Inheritance and binding

Inheritance and binding

Old forum URL: forums.lhotka.net/forums/t/4592.aspx


cafefx posted on Monday, March 31, 2008

I have the parent object Group : BusinessBase<Group> and a child object Asset : Group.

When binding to a BindingSource in a vertical grid, i can only see the parent's fields and none of Asset's fileds will bind.

I know they are there since the debugger shows me the correct object, but, it looks like the grid is binding itself to the base and will not read all of the fields.

Is there a way i can bind to both parent and child? In short: i need all the public fields of the child object.

Thanks

ajj3085 replied on Monday, March 31, 2008

That's going to be difficult.  What if your list contains an instance of the subtype?  Or a different subtype besides Asset?  What should the grid display in those cases?

cafefx replied on Monday, March 31, 2008

I have tried binding the grid to a single item and casted it directly as Asset:

groupsGrid.DataSource = (Asset)Model.GroupList.SelectedGroup;

So in the vertical grid, it will show just a single item, yet, it wont show the Asset properties that are there.

 

Thanks

cafefx replied on Wednesday, April 02, 2008

Just wanted to let everyone know my problem was solved.

The grid actualy did bind correctly.

Using Grid.Rows.Clear() between binds did the trick.

The new properties show up and save correctly.

Copyright (c) Marimer LLC