How to Bind to property of inner object of an object?

Hi,

    In my case, I have two objects like this: 

1    public class Address{
2      private string _country;
3      public string Country { get {return _country;} set {_country=value;}}
4    
5      private string _zip;
6      public string Zip { get {return _zip;} set {_zip=value;}}
7    }
8    
9    public class Person{
10     private string _firstname;
11     public string FirstName{ get {return _firstname;} set {_firstname=value;}}
12     
13     private string _lastname;
14     public string LastName{ get {return _lastname;} set {_lastname=value;}}
15   
16     private Address _location = new Address();
17     public Address Location { get {return _location ;} set {_location =value;}}
18   }

Then I try to bind Person the PersonWebForm. I can bind FirstName like: <%# Eval("FirstName" %>.
But what is the correct binding expression to display Person.Location.Country or Person.Location.Zip?

 Thanks for your consideration and help.

Leo

0
leo
10/15/2007 10:57:13 PM
asp.net.object-datasource 16182 articles. 0 followers. Follow

2 Replies
689 Views

Similar Articles

[PageSpeed] 53

 Like this:

<%# Eval("Location.Country") %>.

 


Mike Banavige
~~~~~~~~~~~~
Need a site code sample in a different language? Try converting it with: http://converter.telerik.com/
0
mbanavige
10/15/2007 11:46:41 PM

Well, good suggestion.

How to extend this to two-way binding?

0
leo
10/16/2007 12:08:09 AM
Reply:

Similar Artilces:

[Object DataSource]
 Hi,Is it possible to binding an object source which has an inner object?If, so How can i do that. And also I want to make sort, filter and grouping  operation on that column.How can i achieve this scenario? Thanks,Prabhu P    Be Confident. Go Nxt Hi: pprabhu.net:Is it possible to binding an object source which has an inner object?   You can either do this in inline code or code behind. For example, in code behind (assume you're using GridView):  protected void GridView5_RowDataBound(object sender, GridViewRowEventArgs e)  &nbs...

detailsview and objects (and objects inside objects inside objects)
hi there!as I was browsing through the posts related to the detailsview I couldn't find someone with the problem I'm facing so I decided to post here...well, I was able to bound an object datasource into my gridview and detailsview, it deletes and shows the data very well, BUT inside the object, there's another object, for example, I have bound a class called Province and inside the Province class there's the Country class indicating the data from the related country, to edit and/or insert I have placed a drop down list so the user selects the country from a drop down list, everything seems ...

Property returns "Object" object that contains custom objects
Hi, I had some difficulties on returning the property of a custom JavaScript Object. Assuming I had a JSObject ObjA that was created using JS_NewObject with my own JSClass ObjA_class. And ObjA_class has one property getObjBs that will return a JavaScript standard "Object" object. And I want this "Object" object has properties that names are same as each ObjB object's property "id" , and the value of each properties is ObjB object. e.g. There are 2 ObjB objects: student1 and student2. The ObjB has a propperty "id": student1.id...

Object Datasource and Custom Object
Hey, I have an object datasource that populates a detailsview.  I know how to update the changes using a BLL method like so: public static UpdateUser(string Username, string Surname); However I would like to use the objects update() method ive created that essentially calls: public static UpdateUser(User user); The question is, how do I access the fields that are contained within the details view?  im guessing .FindControl() but i dont have the ID.  the other way I suppose is to itterate through all the controls within in it?  there must be a better way though? The ...

Property of an object within an object
How do I access the property of an object that is within another object? For example, I have an object consisting of an ArrayList of object. The objects contained in the ArrayList have the properties DisplayText and ValueText. What is the syntax to retrieve those properties? Here's the class file code: Public Class MenuOption Public DisplayText As String Public ValueText As String Public Sub New(DisplayText As String, ValueText As String) MyBase.New() Me.DisplayText = DisplayText Me.ValueText = ValueText End Sub En...

Binding Inner(associalted) objects to Model object from View to Controller
 Here's my scenario.I have an object ClearingHouseRelationship which has a ClearingHouse Object related with it. In the Edit view for this, I have a dropdown populated with list of possible clearing houses. With this edit user should be able th change the ClearingHouse selection and update Clearinghouse relationship object(by making it assicialted to a different ClearinHouse) In the Controller Post action,(Guid Id,  ClearingHouseRelationship model) are passed in. The problem here I'm facing is, basic properties bound to Text boxes and other controls get populated to the Cle...

Object Session
Hi!, I have a file named cDatos.cs with the following lines:  this.usuario = System.Web.HttpContext.Current.Session["usuario"].ToString(); this.contrasena = System.Web.HttpContext.Current.Session["password"].ToString(); this.obtenerConexion(System.Web.HttpContext.Current.Session["nombrecompania"].ToString());  I call this code from another class who I instantiate from an aspx page, but I receive the following error:{"Object reference not set to an instance of an object."} Any hint on this?regards, -eduardo s.m. &nbs...

Error in Data Binding Of Repeater Object of a WebUserControl: "Object reference not set to an instance of an object."
Hi all dudes, I have written the following Code below for Bind a Repeater object in a WebUserControl Object.When I want to set the the DataSource property of Repeater, It encounters the following error:"Object reference not set to an instance of an object."Line 37:     Reader = Cmd.ExecuteReader()Line 38:     Me.Rpt.DataSource = ReaderLine 39:     Me.Rpt.DataBind()When I paste this code in a New WebForm, it doesn't have any problems.So can anyone help me plz ?Thanks in Advance.Public Sub BindRepeater2(ByVal GroupID As String) ...

Difference between object is Nothing, object = Nothing and isNothing(Object)
Hi Is there a difference between object is Nothing, object = Nothing and isNothing(Object) Examples: If customParameter.Value Is Nothing Then If customParameter.Value = Nothing Then If isNothing(customParameter.Value) Then Thanks in advacneRegards,Prabu G~~~ If the reply answered is correct for your question please mark it as answered. This would help people know that the question has been answered. ~~~ Apparently there is a difference in the code generated by the compiler. You may find this article interesting: http://www.thescripts.com/forum/thread352342.html /Kl...

Cannot assign object of type object to variable of type object
Does anyone know if this problem has been corrected yet and if so what EBF for 7.02. Any help would be greatly appreciated. Thanks in advance. -- Thanks David Warner I'm confused. The only data type I can see of type object is an enumerated data type that takes values like Window! Can you give us a code snippet of what functionality fails? I'd be glad to test it in the latest EBF. Let us know, Terry [TeamSybase] and Sequel the techno-kitten www.techno-kitten.com On Tue, 25 Apr 2000 13:18:15 -0400, in powersoft.public.powerbuilder.general David Warner <...

Object reference not set to an instance of an object. System.NullReferenceException: Object reference not set to an instance of an object.
Here's the scenario I have a running code in my localhost using windows xp with microsoft visual studio .net 2003 installed. No problem running the application. But when I transfered the application to a windows server no microsoft visual studio .net 2003 installed. i encountered Object reference not set to an instance of an object. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.NullReferenceException: Object ref...

From record to Object: What object?
Following up from my previous post about converting all my Record databases to Object based databases. What is the best Class I should use in my case? Original Record looks like this: {code} TLiveStationDTB = record FirstSinceRestart : boolean; ExistingRecord : boolean; SourceType : byte; Callsign, LastCall : ansistring; Tactical : ansistring; FirstHeardDateTime, LastHeardDateTime : TSystemTime; StartTSecs, LastHeardTSecs, SecsSinceRestart : cardinal; RawData : ansistring; // etc end; {code} ...

Recreate server object, sas object, cert objects...
hi, after having some problems with our Node2 of our sles10sp3+oes2sp3 cluster we restored Node2 (virtualized server) from backup and had to restore the - node2 server object - node2 sys volume object (they were deleted for some reason) After restore we had certificate problems with node 2, so we deleted the SAS service object and all certs of node 2. Everything seems to be fine, except we cannot create a new SAS object. Over iManager>Novell Certificate Server > Create SAS Service Object we chose node2 and create a sas object -> successful. But if we navigat...

RE: Objects in an object?
Chris <chrisp3623@comcast.net> asked: > I'm not exactly sure what its called but for example, when > using mod_perl, I see the following: > > $r->prev->uri > > How do you create something like this? $r is an object of some class. prev is a method of that class. It returns an object on which the method uri is called. Or consider this example: #!/usr/bin/perl -w use strict; package Fruit; sub new { my $class = shift; my $self = {}; bless $self, $class; return $self; } sub __getset { my( $self, $quality, $value ) =...

Web resources about - How to Bind to property of inner object of an object? - asp.net.object-datasource

Property - Wikipedia, the free encyclopedia
In abstraction, property is that which belongs to or with something, whether as an attribute or as a component of said thing. For the significant ...

Property - Wikipedia, the free encyclopedia
This article may require copy editing for grammar, style, cohesion, tone, or spelling . You can assist by editing it . In abstract, property ...

Thousands of dollars of property stolen from Port Augusta home during Christmas break-in - AdelaideNow ...
DEFENCE medals and unique jewellery are among thousands of dollars of property stolen during a break-in at a Port Augusta home over Christmas. ...

Police raid elaborate underground hydroponic set-up in remote property
An eight-year-old boy was discovered locked in a tiny room within a shed on a remote property where his family allegedly built one of the most ...

Police raid elaborate underground hydroponic set-up in remote property
An eight-year-old boy was discovered locked in a tiny room within a shed on a remote property where his family allegedly built one of the most ...

Mount Isa Police crackdown nets 20 people over property theft - The Courier-Mail Search Search
ABOUT 20 people have been charged, including 17 juveniles, after a series of break and enters and thefts in Mount Isa.

Bomb squad called to Qld property
TWO men have been charged after police found explosives at a property in Helidon.

Police raid elaborate underground hydroponic set-up in remote property
An eight-year-old boy was discovered locked in a tiny room within a shed on a remote property where his family allegedly built one of the most ...

Macquarie Bank makes a bid for property portal, onthehouse.com.au
Property software and online services company Onthehouse Holdings Limited has received an unsolicited takeover offer from a consortium led by ...

Police raid elaborate underground hydroponic set-up in remote property
An eight-year-old boy was discovered locked in a tiny room within a shed on a remote property where his family allegedly built one of the most ...

Resources last updated: 1/7/2016 2:37:41 AM