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

S

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
 
S

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,997
Messages
2,570,239
Members
46,828
Latest member
LauraCastr

Latest Threads

Top