How do i bind a DetailsView to a Business Object's sub object's properties? I'm not sure that question means much yet so let me explain:
I have a "Customer" object which contains properties etc related to my customers (first name, last name etc)
Public Property FirstName() As String
Get
Return _firstName.Trim()
End Get
Set(ByVal value As String)
If value IsNot Nothing Then
_firstName = value.Trim()
End If
End Set
End Property
Public Property Lastname() As String
Get
Return _lastName.Trim()
End Get
Set(ByVal value As String)
If value IsNot Nothing Then
_lastName = value.Trim()
End If
End Set
End Property
The mailing address of the Customer object is actually a "pointer" to another object
Public Property MailAddress() As MailAddress
Get
Return _mailaddress
End Get
Set(ByVal value As MailAddress)
If value IsNot Nothing Then
_mailaddress = value
End If
End Set
End Property
The MailAddress Object contains the properties for a mailing address e.g.:
Public Property Address1() As String
Get
Return _address1.Trim()
End Get
Set(ByVal value As String)
If value IsNot Nothing Then
_address1 = value.Trim()
End If
End Set
End Property
Public Property Address2() As String
Get
Return _address2.Trim()
End Get
Set(ByVal value As String)
If value IsNot Nothing Then
_address2 = value.Trim()
End If
End Set
End Property
So to set properties of the customer object I can do this:
customer.FirstName =
customer.Lastname =
customer.MailAddress.Addre
ss1 =
customer.MailAddress.Addre
ss2 =
However I cant get at the MailAddress properties from within the DetailsView. I thought I could do this:
<asp:BoundField DataField="MailAddress.Add
ress1" HeaderText="Address 1" />
However that doesnt work and if try and just use the VS wizard to bind the DetailsView to the Business Object only the String fields are generated in the DetailsView. The MailAddress sub object is completely ignored.
How do I tackle this? Do I have to create separate address properties in the customer object that just act as pointers to the properties in the address object.
Thanks for your help