Binding array to a listbox error

P

pauled

Hello all,

Framework 1.1 VS 2003 Binding listbox.

I have an array of objects that I am trying to use as the datasource
for a listbox. The array is returned from a webservice and seems to be
populated ok, see this text from my Autos pane in VS, once the
datasource property has been set.

- DataSource {System.Array} System.Object
- [0] {RiskReport.TLDManager.Country} RiskReport.TLDManager.Country
System.Object {RiskReport.TLDManager.Country} System.Object
CountryID 11 int
Name "Australia" string
TLDs <undefined value> RiskReport.TLDManager.TLD[]
+ [1] {RiskReport.TLDManager.Country} RiskReport.TLDManager.Country
+ [2] {RiskReport.TLDManager.Country} RiskReport.TLDManager.Country
+ [3] {RiskReport.TLDManager.Country} RiskReport.TLDManager.Country
+ [4] {RiskReport.TLDManager.Country} RiskReport.TLDManager.Country
+ [5] {RiskReport.TLDManager.Country} RiskReport.TLDManager.Country
+ [6] {RiskReport.TLDManager.Country} RiskReport.TLDManager.Country
+ [7] {RiskReport.TLDManager.Country} RiskReport.TLDManager.Country
+ [8] {RiskReport.TLDManager.Country} RiskReport.TLDManager.Country


As you can see (I've opened the first array item) each Country object
contains 3 properties (CountryID,Name and TLDs) and I am trying to set
the text field to name and the value to CountryID:-

this.lbCountries.DataSource = api.GetCountries();
this.lbCountries.DataTextField = "Name";
this.lbCountries.DataValueField = "CountryID";
this.lbCountries.DataBind();


However on binding I get the error 'RiskReport.TLDManager.Country' does
not contain a property with the name Name. It is spelt correctly and
there are no leading or trailing spaces, this also applies to the
CountryID if I comment out the line to set the DataTextField.

Any help appreciated.

Paul
 
P

pauled

apologies for the re-post, please see thread labbelled "Listbox
Databinding to array of simple objects fails "

thanks

Paul
 

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

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,822
Latest member
israfaceZa

Latest Threads

Top