error while clearing combobox

karunam

Member
Joined
Aug 1, 2005
Messages
11
Programming Experience
Beginner
hi,


when i give cmbemp.items.clear() following is the error that i get.
"cannot modify item collection when datasource property is set.How can i overcome this problem


i am using datareader to fetch values from sqlserver and filling the combobox.

thanks in advance
karuna
 
When you use data binding you can't add or remove items directly. The ComboBox is purely there to display what is in the DataSource, so you would either need to clear the values from the data source itself, or else set the DataSource property to Nothing, which removes the binding.
 
Back
Top