Databinding Question

B

Big Dave

Good morning. I am trying to bind a datagrid to a custom business
object. One of the properties is another object, but I can't seem to
bind to that. Here is an example:

Public Class Company
Private _companyName as string
Public Property CompanyName as string
Get
Return _companyName
End Get
Set(Value as string)
_companyName = Value
End Set

Private _parentCompany as Company
Public Property ParentCompany as Company
Get
Return ParentCompany
End Get
Set(Value as Company)
_parentCompany = Value
End Set
End Class

I have a collection class that holds companies. I can bind a datagrid
to the collections CompanyName property, but not the the
ParentCompany.CompanyName property. Does anyone have any thoughts on
how to do that?

Thanks for your help.

Big Dave
 
K

Karl Seguin

<%# DataBinder.Eval(Container.DataItem, "ParentCompany.CompanyName") %>

or

<%# ctype(Container.DataItem, Company).ParentCompany.CompanyName %>


Karl
 

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

Top