Home All Groups Group Topic Archive Search About

ASP.NET 2.0 - How to databind to nested (hierarchical) business objects?

Author
8 Sep 2006 8:10 PM
style
Hi everybody

Is it somehow possible to databind a control to a nested business object in
ASP.NET 2.0?

Let's say I have a business object "User" with the properties "Name"
(string), "Age" (int) and "Place" whereas Place is a reference to another
business object of the type Location. The class Location has the properties
"ZipCode" (int) and "City" (string).

Now I can bind my control to Name and Age because these properties are
primitive data types. But I don't know how to bind it to the the City
property of the nested object Place.

Any ideas? Maybe .NET 2.0 has some other happy surprises I didn't know of
yet, f.e. something like Bind("Location.City")...  : )

Kind regards
Thomas

Author
15 Sep 2006 5:21 PM
Amar
Any luck on this?

Trying to do the same thing
Author
15 Sep 2006 10:10 PM
style
No, I haven't found an answer yet. Anybody any ideas?

As a workaround I did the following... I am exposing the City (=property of
the nested Location class) in the User class as a property:

public string City
{
    get
    {
        return myLocation.City;
    }
}

Thus I can databind to the City property.

Kind regards
Thomas