Data Binding

T

Tim

Hi All,
Thank you in advance. I am trying to bind a DropDownList to a custom
object. Below is what I have:

Public Class Companies
Inherits Generic.List(of Company)
End Class

Public Class Company
Private _id as integer
Private _Contact as User
<--snip-->
Public Property ID() as Integer
Get
Return _id
End Get
Set(byVal value as integer)
_id = value
End Set
End Property
Public Property Contact() as User
Get
Return _Contact
End Get
Set(byVal value as User)
_Contact = value
End Set
End Property
<--snip-->
End Class

Public Class User
Private _id as integer
Private _FullName as string
<--snip-->
Public Property ID() as Integer
Get
Return _id
End Get
Set(byVal value as integer)
_id = value
End Set
End Property
Public Property FullName () as String
Get
Return _ FullName
End Get
Set(byVal value as String)
_ FullName = value
End Set
End Property
<--snip-->
End Class

Public Class DataAccessLayer
Public Shared Function GetAllCompanies() as Companies
<--Do stuff here-->
End function
End Class

Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load
If Not IsPostBack() Then
ddlContacts.DataSource = DataAccessLayer.GetAllCompanies()
ddlContacts.DataTextField = "User.FullName"
ddlContacts.DataBind()
End If
End Sub


The error I am getting is: "DataBinding: 'Company' does not
contain a property with the name 'User.FullName'."

So my question is: How do I get around this error? Is there a better
approach to what I am doing? Any help would be GREATLY appreciated.

Thanks again for your assistance,
Tim
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,069
Latest member
SimplyleanKetoReviews

Latest Threads

Top