P
Paul
Hi All,
Framework 1.1 listbox control unable to DataBind
I've been googling for an answer to this query that appears quite a lot, but
none, it seem, answers my problem directly.
I am populating a listbox with an array of very simple "Country" objects via
a WebService. The Country class contains CountryID,TLDs and Name properties
each of which have a getter and setter (I found that properties without
setters are not serialised).
During debug I can see the datasource of my listbox and that it contains 13
items, each of which is a Country object, including the "Name" and
"CountryID" properties and these have values.
However on Binding the lisbox to the datasource I get the error
"DataBinder.Eval: 'RiskReport.TLDManager.Country' does not contain a
property with the name Name. "
Name is not miss-spelt nor is CountryID (If commenting out the setting of
the datatextfield I get the same error with CountryID) and neither has
leading or trailing spaces etc
Bidning code
this.lbCountries.DataSource = api.GetCountries();
this.lbCountries.DataTextField = "Name";
this.lbCountries.DataValueField = "CountryID";
this.lbCountries.DataBind();
Copy of Auto's when viewing the DataSource property of the listbox in
question.
-- lbCountries {System.Web.UI.WebControls.ListBox}
System.Web.UI.WebControls.ListBox
- System.Web.UI.WebControls.ListControl {System.Web.UI.WebControls.ListBox}
System.Web.UI.WebControls.ListControl
- 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
+ [9] {RiskReport.TLDManager.Country} RiskReport.TLDManager.Country
+ [10] {RiskReport.TLDManager.Country} RiskReport.TLDManager.Country
+ [11] {RiskReport.TLDManager.Country} RiskReport.TLDManager.Country
+ [12] {RiskReport.TLDManager.Country} RiskReport.TLDManager.Country
Any help appreciated.
Paul
Framework 1.1 listbox control unable to DataBind
I've been googling for an answer to this query that appears quite a lot, but
none, it seem, answers my problem directly.
I am populating a listbox with an array of very simple "Country" objects via
a WebService. The Country class contains CountryID,TLDs and Name properties
each of which have a getter and setter (I found that properties without
setters are not serialised).
During debug I can see the datasource of my listbox and that it contains 13
items, each of which is a Country object, including the "Name" and
"CountryID" properties and these have values.
However on Binding the lisbox to the datasource I get the error
"DataBinder.Eval: 'RiskReport.TLDManager.Country' does not contain a
property with the name Name. "
Name is not miss-spelt nor is CountryID (If commenting out the setting of
the datatextfield I get the same error with CountryID) and neither has
leading or trailing spaces etc
Bidning code
this.lbCountries.DataSource = api.GetCountries();
this.lbCountries.DataTextField = "Name";
this.lbCountries.DataValueField = "CountryID";
this.lbCountries.DataBind();
Copy of Auto's when viewing the DataSource property of the listbox in
question.
-- lbCountries {System.Web.UI.WebControls.ListBox}
System.Web.UI.WebControls.ListBox
- System.Web.UI.WebControls.ListControl {System.Web.UI.WebControls.ListBox}
System.Web.UI.WebControls.ListControl
- 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
+ [9] {RiskReport.TLDManager.Country} RiskReport.TLDManager.Country
+ [10] {RiskReport.TLDManager.Country} RiskReport.TLDManager.Country
+ [11] {RiskReport.TLDManager.Country} RiskReport.TLDManager.Country
+ [12] {RiskReport.TLDManager.Country} RiskReport.TLDManager.Country
Any help appreciated.
Paul