Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

I'm getting the following error when trying to set a datasource property to a listbox:

 

"Item collection can't be modified if the Datasource property is set".

 

I want to add a default item to the listbox after the data is loaded, but I get the above msg:

 

Here is my code:

 

cboCustomerID.DataSource = DsCustomerID1.tblCustomerID

cboCustomerID.ValueMember = DsCustomerID1.tblCustomerID.Columns("CUSTOMER_ID").ToString

cboCustomerID.DisplayMember = DsCustomerID1.tblCustomerID.Columns("CUSTOMER_ID").ToString

cboCustomerID.Items.Insert(0, "ALL")

 

Does anyone know how I can add a default item to the listbox?

Thanks,

 

Bill Yeager (MCP, BCIP)

Microsoft Certified Professional

Brainbench Certified Internet Professional, .Net Programmer, Computer Programmer

YeagerTech Consulting, Inc.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...