This is a migrated thread and some comments may be shown as answers.

Binding to Sub Objects

3 Answers 71 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Ryan
Top achievements
Rank 1
Ryan asked on 04 Aug 2008, 05:30 PM
I'm trying to bind a radgridview to a generic list of objects.

Each object in my generic list contains yet another class object.

For instance, I want the columns in my grid view to be like this:

Row1Column1 = GerericList(0).Property1
Row1Column2 = GerericList(0).Property2

..this works for me... but I haven't found a way to do this...

Row1Column3 = GerericList(0).Property3.SubProperty1
Row1Column4 = GerericList(0).Property3.SubProperty2

Make sense?
Is this possible when I bind a grid view to a generic list?

Ryan



3 Answers, 1 is accepted

Sort by
0
Julian Benkov
Telerik team
answered on 06 Aug 2008, 09:22 AM
Hello Ryan,

The reported scenario is possible in RadGridView but I would need some details about your specific case. Please open a new support ticket and send us a simple example to reproduce you problem locally.

Thank you in advance.

Sincerely yours,
Julian Benkov
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Christian
Top achievements
Rank 1
answered on 08 Jan 2009, 08:41 AM
Hi,
I have a similar problem. I use a generic list of type List <person>.
Every person has the name and first name (both a strings) and exactly one address type of address. The class address includes, among other things, the zip code as a string. I want to dispely the names of persons and the zip code in the GridView.
It would be helpful if I could use the design mode.

For suggestions, I would be grateful.
Christian
0
Julian Benkov
Telerik team
answered on 09 Jan 2009, 03:49 PM
Hello Christian,

You can bind the RadGridView to your generic list of type List <Person>. Then set FieldName of Address column to 'Address.Zip' to view sub property. 

radGridView1.Columns["Address"].FieldName = "Address.Zip"

This scenario is valid also for designtime, when you add new data source from object, map your custom object and bind to RadGridView. You can expand MasterGridViewTemplate property in PropertyGrid of VS and open Columns editor, then you can change FieldName of Address column to 'Address.Zip'

Please view the DataBinding example in our QSF.

Sincerely yours,
Julian Benkov
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
GridView
Asked by
Ryan
Top achievements
Rank 1
Answers by
Julian Benkov
Telerik team
Christian
Top achievements
Rank 1
Share this question
or