|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
ASP.NET 2.0 - How to databind to nested (hierarchical) business objects?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 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
Creating composite web controls
Custom control with ListBox Selecting a value from a Gridview Control HyoerLink - need 2 params Select text in asp:textbox Failed to load viewstate. Auto postback in dropdownlist WebParts - can you transfer one users choice to all users? Event Handler for Control in a Nested Datagrid BaseValidator - How to stop it from rendering "visibility:hidden" |
|||||||||||||||||||||||