C# DevExpress XtraGrid, bind to property of nested class

Suresh picture Suresh · Feb 20, 2011 · Viewed 8.8k times · Source

It's easy to bind an XtraGrid control to a class by setting the FieldName for each column to the name of a property in the underlying class. We have now encountered a situation in which we would like to display data from a class nested in the underlying class.

i.e. we have a "User" class which contains a property called "Address" which is another class called "Address". Within Address are properties like Street, City etc.

We would like to display on the grid the UserName (from User class) and Street (from the Address class). Is this possible?

Please note that Address is not a List, it is a class nested inside of the User class.

We have tried setting the grid column FieldName to "Address.Street" however this doesn't work to pickup the data. I am hoping that this is possible, it seems an elementary feature to not support.

Answer

Aseem Gautam picture Aseem Gautam · Feb 20, 2011