473,385 Members | 1,798 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Databinding Question

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 ***
Nov 19 '05 #1
2 804
<%# 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" <pr******************@yahoo.com> wrote in message
news:eR**************@TK2MSFTNGP09.phx.gbl...
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 ***

Nov 19 '05 #2
That first one worked, thanks for your help!

Big Dave

*** Sent via Developersdex http://www.developersdex.com ***
Nov 19 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Victor Jones | last post by:
I have a general question about the approach towards databinding controls with objects. Apart from the databinding offered by .NET to bind data, it can be extended to have the same behavior with...
0
by: Victor Jones | last post by:
I have a general question about the approach towards databinding controls with objects. Apart from the databinding offered by .NET to bind data, it can be extended to have the same behavior with...
4
by: Jason S | last post by:
I haven't been able to find a clear answer to this and I'm hoping someone could enlighten me. As pertains to databinding a control in a repeating fashion(datagrid, repeater, etc.) what event...
4
by: dtblankenship | last post by:
Hello everyone, I know this question has been asked many times in the forums, and after spending a few days reading, I am still confused as to the answer. I have a ListBox (lstBox),...
2
by: Al Smith | last post by:
I kind of understand how the below works, however I am trying to do it at runtime vrs design time. <asp:TextBox id="TextBox1" runat="server" Text='<%# StateList.SelectedItem.Text...
2
by: Shane | last post by:
When I click on the DataBinding in the properties window a list of options open up called Advanced,Tag and Text. I would like to know what Tag and Text are set to? I hope to Bind a text box to a...
9
by: Dennis | last post by:
I have tried using Databinding for my application but always seem to find it very restrictive (maybe I don't completely understand it enough). I always seem to find it much easier to display a...
5
by: Mark R. Dawson | last post by:
Hi all, I may be missing something with how databinding works but I have bound a datasource to a control and everything is great, the control updates to reflect the state of my datasource when I...
1
by: Zak Lomakus | last post by:
Hi, From my main page (default.aspx) I am calling another .aspx (e.g. otherpage.aspx) page through Javascript using window.showModalDialog. otherpage.aspx has a databoud control (webchart),...
0
by: rb | last post by:
I'm struggling with (probably) basic things using SqlDataSource and DataList. Here's the problem: I need to read the resultset returned by SqlDataSource to perform actions related to visual...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.