Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Databinding Question

Reply
Thread Tools

Databinding Question

 
 
Big Dave
Guest
Posts: n/a
 
      07-01-2005
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

*** Sent via Developersdex http://www.developersdex.com ***
 
Reply With Quote
 
 
 
 
Karl Seguin
Guest
Posts: n/a
 
      07-01-2005
<%# DataBinder.Eval(Container.DataItem, "ParentCompany.CompanyName") %>

or

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


Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/ - New and Improved (yes, the popup is annoying)
http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
come!)


"Big Dave" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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
>
> *** Sent via Developersdex http://www.developersdex.com ***



 
Reply With Quote
 
 
 
 
Big Dave
Guest
Posts: n/a
 
      07-01-2005
That first one worked, thanks for your help!

Big Dave

*** Sent via Developersdex http://www.developersdex.com ***
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Databinding expressions are only supported on objects that have a DataBinding event jobs ASP .Net 0 09-25-2007 11:54 PM
Gridview encoding, or how to run commands before gridview's default databinding, or, how do I disable default databinding at all? Sergei Shelukhin ASP .Net 1 11-12-2006 01:43 PM
DataGrid Custom Column Error when DataBinding "does not contain a definition for 'DataBinding'" Earl Teigrob ASP .Net Datagrid Control 1 03-01-2004 04:52 AM
databinding question Jason S ASP .Net 4 12-05-2003 06:55 PM
Nested repeater databinding question Ed Allan ASP .Net 0 08-01-2003 01:10 PM



Advertisments