[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

Question
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

7.2

Binding a DetailsView to a "sub" Object of a Business Object

Asked by g-spot in Programming for ASP.NET, .NET, Visual Basic Programming

Tags: VB ASP.net

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.Address1 =
                customer.MailAddress.Address2 =

However I cant get at the MailAddress properties from within the DetailsView. I thought I could do this:

<asp:BoundField DataField="MailAddress.Address1" 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
[+][-]04/16/08 03:08 AM, ID: 21366150Accepted Solution

View this solution now by starting your 30-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

About this solution

Zones: Programming for ASP.NET, .NET, Visual Basic Programming
Tags: VB ASP.net
Sign Up Now!
Solution Provided By: g-spot
Participating Experts: 2
Solution Grade: B
 
[+][-]04/16/08 01:48 AM, ID: 21365832Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]04/16/08 03:32 AM, ID: 21366230Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]04/20/08 07:41 AM, ID: 21396150Administrative Comment

Experts Exchange has a courteous staff of administrators who help members get the most out of the website by means of administrative comments like this one.

Start your 30-day free trial to view this Administrative Comment or ask the Experts your question.

 
 
Loading Advertisement...
20091111-EE-VQP-92 / EE_QW_2_20070628