ListBox - Items collections and DataSource

G

Guest

Hey All,

I am having a little trouble with the ListBox's Items collection property. I
am populating the ListBox with data contained in an SQL table using
SQLDataAdapter and DataSet.

I have set the "DataSource", "DisplayMember", and "ValueMember" properties
of the ListBox correctly like below:

lbTechnician.DataSource = TechnicianDataSet.Tables[0];
bTechnician.DisplayMember = "Name";
lbTechnician.ValueMember = "Name";

Where "lbTechnician" is the name of the ListBox and "Name" is one of the
columns of the SQL table.

The application is compiling with 0 errors and 0 warning. But when I try to
run it JIT (Just-In-Time) Debugging is giving me following error:

"Can't modify the Items collection when the DataSource property is set"

I checked the Items collection for the ListBox. Its empty. I dont have any
idea how to fix this error.

Can anybody help me out.

Thanks in advance,
Prasad
 
G

Guest

FYI --

I fixed it. I had set the "Sorted" property of the ListBox to "true". You
cant use that property if you are using DataSet to populate the ListBox. You
have to use ORDER BY within your SQL Query.

Prasad
 
P

Paul W.

Hi Prasad,

I understand you did some Syspro -> MS CRM integration. I wonder if
you wouldn't mind emailing me so we could discuss?
(e-mail address removed).

Thanks.

Prasad said:
FYI --

I fixed it. I had set the "Sorted" property of the ListBox to "true". You
cant use that property if you are using DataSet to populate the ListBox. You
have to use ORDER BY within your SQL Query.

Prasad

Prasad said:
Hey All,

I am having a little trouble with the ListBox's Items collection property. I
am populating the ListBox with data contained in an SQL table using
SQLDataAdapter and DataSet.

I have set the "DataSource", "DisplayMember", and "ValueMember" properties
of the ListBox correctly like below:

lbTechnician.DataSource = TechnicianDataSet.Tables[0];
bTechnician.DisplayMember = "Name";
lbTechnician.ValueMember = "Name";

Where "lbTechnician" is the name of the ListBox and "Name" is one of the
columns of the SQL table.

The application is compiling with 0 errors and 0 warning. But when I try to
run it JIT (Just-In-Time) Debugging is giving me following error:

"Can't modify the Items collection when the DataSource property is set"

I checked the Items collection for the ListBox. Its empty. I dont have any
idea how to fix this error.

Can anybody help me out.

Thanks in advance,
Prasad
 
G

Guest

Paul,

I have sent you an email.

Prasad

Paul W. said:
Hi Prasad,

I understand you did some Syspro -> MS CRM integration. I wonder if
you wouldn't mind emailing me so we could discuss?
(e-mail address removed).

Thanks.

Prasad said:
FYI --

I fixed it. I had set the "Sorted" property of the ListBox to "true". You
cant use that property if you are using DataSet to populate the ListBox. You
have to use ORDER BY within your SQL Query.

Prasad

Prasad said:
Hey All,

I am having a little trouble with the ListBox's Items collection property. I
am populating the ListBox with data contained in an SQL table using
SQLDataAdapter and DataSet.

I have set the "DataSource", "DisplayMember", and "ValueMember" properties
of the ListBox correctly like below:

lbTechnician.DataSource = TechnicianDataSet.Tables[0];
bTechnician.DisplayMember = "Name";
lbTechnician.ValueMember = "Name";

Where "lbTechnician" is the name of the ListBox and "Name" is one of the
columns of the SQL table.

The application is compiling with 0 errors and 0 warning. But when I try to
run it JIT (Just-In-Time) Debugging is giving me following error:

"Can't modify the Items collection when the DataSource property is set"

I checked the Items collection for the ListBox. Its empty. I dont have any
idea how to fix this error.

Can anybody help me out.

Thanks in advance,
Prasad
 

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

Top