How do I Data Bind a GridView Control to an object data source that has imbedded objectshttp://forums.asp.net/t/997141.aspx/1?How+do+I+Data+Bind+a+GridView+Control+to+an+object+data+source+that+has+imbedded+objectsTue, 06 Jun 2006 20:14:10 -04009971411307058http://forums.asp.net/p/997141/1307058.aspx/1?How+do+I+Data+Bind+a+GridView+Control+to+an+object+data+source+that+has+imbedded+objectsHow do I Data Bind a GridView Control to an object data source that has imbedded objects <p>What follows are snippets of two classes that I am using:</p> <p>public class Location<br> {<br> &nbsp;private string locationCode;</p> <p>&nbsp;public String LocationCode<br> &nbsp;{<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; get { return locationCode;}<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; set { locationCode = value; }<br> &nbsp;}<br> }</p> <p><br> public class User<br> {<br> &nbsp;private Location location;</p> <p>&nbsp;public Location Location<br> &nbsp;{<br> &nbsp;&nbsp;&nbsp;&nbsp; get { return location;}<br> &nbsp;&nbsp;&nbsp;&nbsp; set { location = value}<br> &nbsp;}<br> }</p> <p>&nbsp;I have bound a GridView control to a collection of User objects.&nbsp; Within the GridView I need to display the LocationCode.&nbsp; On the GridView Smart Tag,&nbsp;I went to the Edit Columns dialog.&nbsp; No matter what I&nbsp;entered&nbsp;for the Data Field (I&nbsp;tried User.Location.LocationCode) I was not able to&nbsp;Bind to the location Code.&nbsp;</p> <p>Can this be accomplished without creating a property in the User Class that exposes the Location Code?</p> <p>Thanks</p> <p>&nbsp;</p> 2006-06-06T20:14:10-04:00