473,782 Members | 2,454 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Listbox Databinding to array of simple objects fails

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.Eva l: 'RiskReport.TLD Manager.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.lbCountrie s.DataSource = api.GetCountrie s();
this.lbCountrie s.DataTextField = "Name";
this.lbCountrie s.DataValueFiel d = "CountryID" ;
this.lbCountrie s.DataBind();

Copy of Auto's when viewing the DataSource property of the listbox in
question.
-- lbCountries {System.Web.UI. WebControls.Lis tBox}
System.Web.UI.W ebControls.List Box
- System.Web.UI.W ebControls.List Control {System.Web.UI. WebControls.Lis tBox}
System.Web.UI.W ebControls.List Control
- DataSource {System.Array} System.Object
- [0] {RiskReport.TLD Manager.Country } RiskReport.TLDM anager.Country
System.Object {RiskReport.TLD Manager.Country } System.Object
CountryID 11 int
Name "Australia" string
TLDs <undefined valueRiskReport .TLDManager.TLD[]
+ [1] {RiskReport.TLD Manager.Country } RiskReport.TLDM anager.Country
+ [2] {RiskReport.TLD Manager.Country } RiskReport.TLDM anager.Country
+ [3] {RiskReport.TLD Manager.Country } RiskReport.TLDM anager.Country
+ [4] {RiskReport.TLD Manager.Country } RiskReport.TLDM anager.Country
+ [5] {RiskReport.TLD Manager.Country } RiskReport.TLDM anager.Country
+ [6] {RiskReport.TLD Manager.Country } RiskReport.TLDM anager.Country
+ [7] {RiskReport.TLD Manager.Country } RiskReport.TLDM anager.Country
+ [8] {RiskReport.TLD Manager.Country } RiskReport.TLDM anager.Country
+ [9] {RiskReport.TLD Manager.Country } RiskReport.TLDM anager.Country
+ [10] {RiskReport.TLD Manager.Country } RiskReport.TLDM anager.Country
+ [11] {RiskReport.TLD Manager.Country } RiskReport.TLDM anager.Country
+ [12] {RiskReport.TLD Manager.Country } RiskReport.TLDM anager.Country

Any help appreciated.

Paul
Jul 17 '06 #1
6 2341
Are they really properties or just fields? Are they public?

Karl

--
http://www.openmymind.net/
http://www.codebetter.com/
"Paul" <pa***********@ removethisbitho tmail.comwrote in message
news:eh******** ******@TK2MSFTN GP04.phx.gbl...
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.Eva l: 'RiskReport.TLD Manager.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.lbCountrie s.DataSource = api.GetCountrie s();
this.lbCountrie s.DataTextField = "Name";
this.lbCountrie s.DataValueFiel d = "CountryID" ;
this.lbCountrie s.DataBind();

Copy of Auto's when viewing the DataSource property of the listbox in
question.
-- lbCountries {System.Web.UI. WebControls.Lis tBox}
System.Web.UI.W ebControls.List Box
- System.Web.UI.W ebControls.List Control
{System.Web.UI. WebControls.Lis tBox} System.Web.UI.W ebControls.List Control
- DataSource {System.Array} System.Object
- [0] {RiskReport.TLD Manager.Country } RiskReport.TLDM anager.Country
System.Object {RiskReport.TLD Manager.Country }
System.Object
CountryID 11 int
Name "Australia" string
TLDs <undefined valueRiskReport .TLDManager.TLD[]
+ [1] {RiskReport.TLD Manager.Country } RiskReport.TLDM anager.Country
+ [2] {RiskReport.TLD Manager.Country } RiskReport.TLDM anager.Country
+ [3] {RiskReport.TLD Manager.Country } RiskReport.TLDM anager.Country
+ [4] {RiskReport.TLD Manager.Country } RiskReport.TLDM anager.Country
+ [5] {RiskReport.TLD Manager.Country } RiskReport.TLDM anager.Country
+ [6] {RiskReport.TLD Manager.Country } RiskReport.TLDM anager.Country
+ [7] {RiskReport.TLD Manager.Country } RiskReport.TLDM anager.Country
+ [8] {RiskReport.TLD Manager.Country } RiskReport.TLDM anager.Country
+ [9] {RiskReport.TLD Manager.Country } RiskReport.TLDM anager.Country
+ [10] {RiskReport.TLD Manager.Country } RiskReport.TLDM anager.Country
+ [11] {RiskReport.TLD Manager.Country } RiskReport.TLDM anager.Country
+ [12] {RiskReport.TLD Manager.Country } RiskReport.TLDM anager.Country

Any help appreciated.

Paul

Jul 17 '06 #2
Hi,

They are public properties with a getter and setter for each.

Thanks

Paul
Karl Seguin [MVP] wrote:
Are they really properties or just fields? Are they public?

Karl

--
http://www.openmymind.net/
http://www.codebetter.com/
"Paul" <pa***********@ removethisbitho tmail.comwrote in message
news:eh******** ******@TK2MSFTN GP04.phx.gbl...
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.Eva l: 'RiskReport.TLD Manager.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.lbCountrie s.DataSource = api.GetCountrie s();
this.lbCountrie s.DataTextField = "Name";
this.lbCountrie s.DataValueFiel d = "CountryID" ;
this.lbCountrie s.DataBind();

Copy of Auto's when viewing the DataSource property of the listbox in
question.
-- lbCountries {System.Web.UI. WebControls.Lis tBox}
System.Web.UI.W ebControls.List Box
- System.Web.UI.W ebControls.List Control
{System.Web.UI. WebControls.Lis tBox} System.Web.UI.W ebControls.List Control
- DataSource {System.Array} System.Object
- [0] {RiskReport.TLD Manager.Country } RiskReport.TLDM anager.Country
System.Object {RiskReport.TLD Manager.Country }
System.Object
CountryID 11 int
Name "Australia" string
TLDs <undefined valueRiskReport .TLDManager.TLD[]
+ [1] {RiskReport.TLD Manager.Country } RiskReport.TLDM anager.Country
+ [2] {RiskReport.TLD Manager.Country } RiskReport.TLDM anager.Country
+ [3] {RiskReport.TLD Manager.Country } RiskReport.TLDM anager.Country
+ [4] {RiskReport.TLD Manager.Country } RiskReport.TLDM anager.Country
+ [5] {RiskReport.TLD Manager.Country } RiskReport.TLDM anager.Country
+ [6] {RiskReport.TLD Manager.Country } RiskReport.TLDM anager.Country
+ [7] {RiskReport.TLD Manager.Country } RiskReport.TLDM anager.Country
+ [8] {RiskReport.TLD Manager.Country } RiskReport.TLDM anager.Country
+ [9] {RiskReport.TLD Manager.Country } RiskReport.TLDM anager.Country
+ [10] {RiskReport.TLD Manager.Country } RiskReport.TLDM anager.Country
+ [11] {RiskReport.TLD Manager.Country } RiskReport.TLDM anager.Country
+ [12] {RiskReport.TLD Manager.Country } RiskReport.TLDM anager.Country

Any help appreciated.

Paul
Jul 17 '06 #3
A small update.

If I construct an array of type Country I can create a list item
manually adding the members of the array as I itterrate through them.
The CountryID and Name values are available (even in the intelliscense)
and the list box appears correct.

So what does the the DataBind() method do differently to what I'm doing
manually for it to fail?

Cheers

Paul

pa****@gmail.co m wrote:
Hi,

They are public properties with a getter and setter for each.

Thanks

Paul
Karl Seguin [MVP] wrote:
Are they really properties or just fields? Are they public?

Karl

--
http://www.openmymind.net/
http://www.codebetter.com/
"Paul" <pa***********@ removethisbitho tmail.comwrote in message
news:eh******** ******@TK2MSFTN GP04.phx.gbl...
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.Eva l: 'RiskReport.TLD Manager.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.lbCountrie s.DataSource = api.GetCountrie s();
this.lbCountrie s.DataTextField = "Name";
this.lbCountrie s.DataValueFiel d = "CountryID" ;
this.lbCountrie s.DataBind();
>
Copy of Auto's when viewing the DataSource property of the listbox in
question.
>
>
-- lbCountries {System.Web.UI. WebControls.Lis tBox}
System.Web.UI.W ebControls.List Box
- System.Web.UI.W ebControls.List Control
{System.Web.UI. WebControls.Lis tBox} System.Web.UI.W ebControls.List Control
- DataSource {System.Array} System.Object
- [0] {RiskReport.TLD Manager.Country } RiskReport.TLDM anager.Country
System.Object {RiskReport.TLD Manager.Country }
System.Object
CountryID 11 int
Name "Australia" string
TLDs <undefined valueRiskReport .TLDManager.TLD[]
+ [1] {RiskReport.TLD Manager.Country } RiskReport.TLDM anager.Country
+ [2] {RiskReport.TLD Manager.Country } RiskReport.TLDM anager.Country
+ [3] {RiskReport.TLD Manager.Country } RiskReport.TLDM anager.Country
+ [4] {RiskReport.TLD Manager.Country } RiskReport.TLDM anager.Country
+ [5] {RiskReport.TLD Manager.Country } RiskReport.TLDM anager.Country
+ [6] {RiskReport.TLD Manager.Country } RiskReport.TLDM anager.Country
+ [7] {RiskReport.TLD Manager.Country } RiskReport.TLDM anager.Country
+ [8] {RiskReport.TLD Manager.Country } RiskReport.TLDM anager.Country
+ [9] {RiskReport.TLD Manager.Country } RiskReport.TLDM anager.Country
+ [10] {RiskReport.TLD Manager.Country } RiskReport.TLDM anager.Country
+ [11] {RiskReport.TLD Manager.Country } RiskReport.TLDM anager.Country
+ [12] {RiskReport.TLD Manager.Country } RiskReport.TLDM anager.Country
>
Any help appreciated.
>
Paul
>
Jul 17 '06 #4
I still think something's wrong with your Country class. DataBind workds
fine against public, non-static/shared properties.

Karl

--
http://www.openmymind.net/
http://www.fuelindustries.com/
<pa****@gmail.c omwrote in message
news:11******** *************@b 28g2000cwb.goog legroups.com...
>A small update.

If I construct an array of type Country I can create a list item
manually adding the members of the array as I itterrate through them.
The CountryID and Name values are available (even in the intelliscense)
and the list box appears correct.

So what does the the DataBind() method do differently to what I'm doing
manually for it to fail?

Cheers

Paul

pa****@gmail.co m wrote:
>Hi,

They are public properties with a getter and setter for each.

Thanks

Paul
Karl Seguin [MVP] wrote:
Are they really properties or just fields? Are they public?

Karl

--
http://www.openmymind.net/
http://www.codebetter.com/
"Paul" <pa***********@ removethisbitho tmail.comwrote in message
news:eh******** ******@TK2MSFTN GP04.phx.gbl...
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.Eva l: 'RiskReport.TLD Manager.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.lbCountrie s.DataSource = api.GetCountrie s();
this.lbCountrie s.DataTextField = "Name";
this.lbCountrie s.DataValueFiel d = "CountryID" ;
this.lbCountrie s.DataBind();

Copy of Auto's when viewing the DataSource property of the listbox in
question.
-- lbCountries {System.Web.UI. WebControls.Lis tBox}
System.Web.UI.W ebControls.List Box
- System.Web.UI.W ebControls.List Control
{System.Web.UI. WebControls.Lis tBox}
System.Web.UI.W ebControls.List Control
- DataSource {System.Array} System.Object
- [0] {RiskReport.TLD Manager.Country } RiskReport.TLDM anager.Country
System.Object {RiskReport.TLD Manager.Country }
System.Object
CountryID 11 int
Name "Australia" string
TLDs <undefined valueRiskReport .TLDManager.TLD[]
+ [1] {RiskReport.TLD Manager.Country } RiskReport.TLDM anager.Country
+ [2] {RiskReport.TLD Manager.Country } RiskReport.TLDM anager.Country
+ [3] {RiskReport.TLD Manager.Country } RiskReport.TLDM anager.Country
+ [4] {RiskReport.TLD Manager.Country } RiskReport.TLDM anager.Country
+ [5] {RiskReport.TLD Manager.Country } RiskReport.TLDM anager.Country
+ [6] {RiskReport.TLD Manager.Country } RiskReport.TLDM anager.Country
+ [7] {RiskReport.TLD Manager.Country } RiskReport.TLDM anager.Country
+ [8] {RiskReport.TLD Manager.Country } RiskReport.TLDM anager.Country
+ [9] {RiskReport.TLD Manager.Country } RiskReport.TLDM anager.Country
+ [10] {RiskReport.TLD Manager.Country } RiskReport.TLDM anager.Country
+ [11] {RiskReport.TLD Manager.Country } RiskReport.TLDM anager.Country
+ [12] {RiskReport.TLD Manager.Country } RiskReport.TLDM anager.Country

Any help appreciated.

Paul

Jul 17 '06 #5
This is the code for my Country class, it's very simple.

namespace TLD.Manager
{

public class Country
{
public Country()
{}

private int _countryid = 0;

private string _name;

private TLD[] _tlds;
public int CountryID
{
get{return this._countryid ;}
set{this._count ryid = value;}
}

public string Name
{
get{return this._name;}
set{this._name = value;}
}

public TLD[] TLDs
{
get{return this._tlds;}
set{this._tlds = value;}
}

public static Country[] GetCountryNames ()
{
SqlConnection con = new
SqlConnection(C onfigurationSet tings.AppSettin gs["DBConn"]);
SqlCommand com = new SqlCommand("up_ SelectCountryNa mes",con);
com.CommandType = CommandType.Sto redProcedure;
ArrayList al = new ArrayList();
con.Open();
SqlDataReader dr = com.ExecuteRead er();
while(dr.Read() )
{
Country c = new Country();
c._countryid = Convert.ToInt32 (dr["CountryID"]);
c._name = dr["Country"].ToString();
al.Add(c);
}
con.Close();
con.Dispose();
com.Dispose();
return (Country[])al.ToArray(typ eof(Country));
}

}

My web service simply provides a web method that returns the result of
the GetCountryNames () method call.

Paul

Karl Seguin [MVP] wrote:
I still think something's wrong with your Country class. DataBind workds
fine against public, non-static/shared properties.

Karl

--
http://www.openmymind.net/
http://www.fuelindustries.com/
<pa****@gmail.c omwrote in message
news:11******** *************@b 28g2000cwb.goog legroups.com...
A small update.

If I construct an array of type Country I can create a list item
manually adding the members of the array as I itterrate through them.
The CountryID and Name values are available (even in the intelliscense)
and the list box appears correct.

So what does the the DataBind() method do differently to what I'm doing
manually for it to fail?

Cheers

Paul

pa****@gmail.co m wrote:
Hi,

They are public properties with a getter and setter for each.

Thanks

Paul
Karl Seguin [MVP] wrote:

Are they really properties or just fields? Are they public?

Karl

--
http://www.openmymind.net/
http://www.codebetter.com/
"Paul" <pa***********@ removethisbitho tmail.comwrote in message
news:eh******** ******@TK2MSFTN GP04.phx.gbl...
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.Eva l: 'RiskReport.TLD Manager.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.lbCountrie s.DataSource = api.GetCountrie s();
this.lbCountrie s.DataTextField = "Name";
this.lbCountrie s.DataValueFiel d = "CountryID" ;
this.lbCountrie s.DataBind();
>
Copy of Auto's when viewing the DataSource property of the listbox in
question.
>
>
-- lbCountries {System.Web.UI. WebControls.Lis tBox}
System.Web.UI.W ebControls.List Box
- System.Web.UI.W ebControls.List Control
{System.Web.UI. WebControls.Lis tBox}
System.Web.UI.W ebControls.List Control
- DataSource {System.Array} System.Object
- [0] {RiskReport.TLD Manager.Country } RiskReport.TLDM anager.Country
System.Object {RiskReport.TLD Manager.Country }
System.Object
CountryID 11 int
Name "Australia" string
TLDs <undefined valueRiskReport .TLDManager.TLD[]
+ [1] {RiskReport.TLD Manager.Country } RiskReport.TLDM anager.Country
+ [2] {RiskReport.TLD Manager.Country } RiskReport.TLDM anager.Country
+ [3] {RiskReport.TLD Manager.Country } RiskReport.TLDM anager.Country
+ [4] {RiskReport.TLD Manager.Country } RiskReport.TLDM anager.Country
+ [5] {RiskReport.TLD Manager.Country } RiskReport.TLDM anager.Country
+ [6] {RiskReport.TLD Manager.Country } RiskReport.TLDM anager.Country
+ [7] {RiskReport.TLD Manager.Country } RiskReport.TLDM anager.Country
+ [8] {RiskReport.TLD Manager.Country } RiskReport.TLDM anager.Country
+ [9] {RiskReport.TLD Manager.Country } RiskReport.TLDM anager.Country
+ [10] {RiskReport.TLD Manager.Country } RiskReport.TLDM anager.Country
+ [11] {RiskReport.TLD Manager.Country } RiskReport.TLDM anager.Country
+ [12] {RiskReport.TLD Manager.Country } RiskReport.TLDM anager.Country
>
Any help appreciated.
>
Paul
>
Jul 18 '06 #6
Yes, that does look normal...

The namespace in the error is RiskReport.TLDM anager.Country and your class
namespace seems to be TLD.Manager I take it it's just a sample typo, but
wanted to point it out incase it leads to anything..

I can't see anything else out of the ordinary...I still think it's something
silly staring both of us in the eyes...

If you want, you can zip up a sample project and send it to me, I'm more
than happy to take a closer look @ it.

Karl
--
http://www.openmymind.net/
http://www.codebetter.com/
<pa****@gmail.c omwrote in message
news:11******** *************@m 73g2000cwd.goog legroups.com...
This is the code for my Country class, it's very simple.

namespace TLD.Manager
{

public class Country
{
public Country()
{}

private int _countryid = 0;

private string _name;

private TLD[] _tlds;
public int CountryID
{
get{return this._countryid ;}
set{this._count ryid = value;}
}

public string Name
{
get{return this._name;}
set{this._name = value;}
}

public TLD[] TLDs
{
get{return this._tlds;}
set{this._tlds = value;}
}

public static Country[] GetCountryNames ()
{
SqlConnection con = new
SqlConnection(C onfigurationSet tings.AppSettin gs["DBConn"]);
SqlCommand com = new SqlCommand("up_ SelectCountryNa mes",con);
com.CommandType = CommandType.Sto redProcedure;
ArrayList al = new ArrayList();
con.Open();
SqlDataReader dr = com.ExecuteRead er();
while(dr.Read() )
{
Country c = new Country();
c._countryid = Convert.ToInt32 (dr["CountryID"]);
c._name = dr["Country"].ToString();
al.Add(c);
}
con.Close();
con.Dispose();
com.Dispose();
return (Country[])al.ToArray(typ eof(Country));
}

}

My web service simply provides a web method that returns the result of
the GetCountryNames () method call.

Paul

Karl Seguin [MVP] wrote:
>I still think something's wrong with your Country class. DataBind workds
fine against public, non-static/shared properties.

Karl

--
http://www.openmymind.net/
http://www.fuelindustries.com/
<pa****@gmail. comwrote in message
news:11******* **************@ b28g2000cwb.goo glegroups.com.. .
>A small update.

If I construct an array of type Country I can create a list item
manually adding the members of the array as I itterrate through them.
The CountryID and Name values are available (even in the intelliscense)
and the list box appears correct.

So what does the the DataBind() method do differently to what I'm doing
manually for it to fail?

Cheers

Paul

pa****@gmail.co m wrote:
Hi,

They are public properties with a getter and setter for each.

Thanks

Paul
Karl Seguin [MVP] wrote:

Are they really properties or just fields? Are they public?

Karl

--
http://www.openmymind.net/
http://www.codebetter.com/
"Paul" <pa***********@ removethisbitho tmail.comwrote in message
news:eh******** ******@TK2MSFTN GP04.phx.gbl...
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.Eva l: 'RiskReport.TLD Manager.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.lbCountrie s.DataSource = api.GetCountrie s();
this.lbCountrie s.DataTextField = "Name";
this.lbCountrie s.DataValueFiel d = "CountryID" ;
this.lbCountrie s.DataBind();

Copy of Auto's when viewing the DataSource property of the listbox
in
question.
-- lbCountries {System.Web.UI. WebControls.Lis tBox}
System.Web.UI.W ebControls.List Box
- System.Web.UI.W ebControls.List Control
{System.Web.UI. WebControls.Lis tBox}
System.Web.UI.W ebControls.List Control
- DataSource {System.Array} System.Object
- [0] {RiskReport.TLD Manager.Country }
RiskReport.TLDM anager.Country
System.Object {RiskReport.TLD Manager.Country }
System.Object
CountryID 11 int
Name "Australia" string
TLDs <undefined valueRiskReport .TLDManager.TLD[]
+ [1] {RiskReport.TLD Manager.Country }
RiskReport.TLDM anager.Country
+ [2] {RiskReport.TLD Manager.Country }
RiskReport.TLDM anager.Country
+ [3] {RiskReport.TLD Manager.Country }
RiskReport.TLDM anager.Country
+ [4] {RiskReport.TLD Manager.Country }
RiskReport.TLDM anager.Country
+ [5] {RiskReport.TLD Manager.Country }
RiskReport.TLDM anager.Country
+ [6] {RiskReport.TLD Manager.Country }
RiskReport.TLDM anager.Country
+ [7] {RiskReport.TLD Manager.Country }
RiskReport.TLDM anager.Country
+ [8] {RiskReport.TLD Manager.Country }
RiskReport.TLDM anager.Country
+ [9] {RiskReport.TLD Manager.Country }
RiskReport.TLDM anager.Country
+ [10] {RiskReport.TLD Manager.Country }
RiskReport.TLDM anager.Country
+ [11] {RiskReport.TLD Manager.Country }
RiskReport.TLDM anager.Country
+ [12] {RiskReport.TLD Manager.Country }
RiskReport.TLDM anager.Country

Any help appreciated.

Paul


Jul 18 '06 #7

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

Similar topics

3
1974
by: jayderk | last post by:
Hello All, I am running in to a situation where the listbox is not refreshing for me. I am using a timer to cycle every second and call the timer_elapsed() event. in the time_elapsed event Method I have code that checks to see if a DB table has been updated.. if so the new new data is uploaded to the listbox by calling lstbox1.datasource = myDBDataSet;
6
2881
by: Chris Leuty | last post by:
I am populating a multiselect Listbox from a dataset, with the content of the listbox filled by one table, and the selections determined from another table. So far, I have been keeping the dataset a denormalized mirror of the database, but I'm not having much luck getting the selection logic down (I haven't found a 'hook' where I can access the listbox object as an object to set the listitem's selected property before it gets rendered).. ...
4
4211
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), SqlConnection (sqlConnection), SqlDataAdapter (daLookupData), SqlDataAdapter (daData), DataSet (dsLookupData), and DataSet (dsData), all created via the IDE during design-time. Here is the design of my simple tables: (An example since I can't post my...
7
10068
by: 00_ChInkPoIntD12 | last post by:
Can anyone confirm there isn't a Sort() method for WebControl Listbox in Asp.net? It is rather simple to write a method to do the sorting, but just wondering I shouldn't invent the wheel if there is already one. C.P.
4
1705
by: KC | last post by:
I'm filling a listbox in my code and I notice that when I run the program the first item in the listbox is always selected. I haven't selected anything though. When I have it run a quick unselect loop I still end up with one item always selected. If I unselect the first item, click on one further down the list and then unselect that one, the first item is automatically selected again. Is this normal? Do I have some property set that I...
1
2780
by: A. Spiehler | last post by:
I'm trying to fill a listBox control with string members from an array of objects. I think using data binding is supposed to be the easiest way to do this. I've never used data binding before and am having trouble getting it to do anything. The relevant code is below, followed by a better explanation of what I'm trying to do. // pseudocode start public delegate string StepMethod();
1
1516
by: pauled | last post by:
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
1
2084
by: lance2001 | last post by:
Hi, After viewing the entire Visual Basic 2005 Express Edition for Beginners video series, I have begun building a database driven application that will make use of listbox1 (multi-select) determining what shows up in listbox2 (multi_select), which determines listbox3, etc.... Each each listbox is populated from a different table in the same database. The databinding examples given in the video seem to leave no way for a
1
4030
by: Sunray | last post by:
I have a form called the sales form and i have 2 sets of listboxes So what happens is. i add items form the bottom set of list boxes which are bound to a data base to the top set of list boxes which are not bound, I select from the bottom set and add to the top set which works fine, but now i decide to remove an item from the top set. when i tried to use a remove item code it worked fine, it did delete the item form the list but it added...
0
9479
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10311
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10146
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9942
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7492
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6733
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5509
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4043
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3639
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.