Monday, July 30, 2007

Show child object properties in GridView

Here we have a simple trick.

I'll introduce my objects first.

Nothing to worry about. If I show you the XML view of the User[], it should looks like below.

Now we can assign this to a GridView.

GridView1.DataSource = UserList;

Dont forget to import the objects namespaces in the page header in the HTML view.



I'm using to show the child object property values in to the grid.

What we are doing here is to match the Parent object property name Home to access the child object. Actually it is a object of Address type. So that I can cast the object to Address type and access the child property Country.

No comments: