ComboBox, ListBox DataSource = null not work

  • Thread starter Thread starter kids_pro
  • Start date Start date
K

kids_pro

Hi,

On form_load() I bind a combobox to a dataset and listbox to a datatable.

When I want to unbind it I call comboBox1.DataSource = null,
listBox1.DataSource = null
It unbind but the Items still persist in the comboBox and listBox. I expect
it to be empty list.

Can anyone tell me how to unbind the comboBox and automatically clear it
items?

Regards,
kids
 
Hi,

I have no experiences with DataBinding but i can recommend
to try:

comboBox1.DataSource = null;
comboBox1.DataBindings.Clear();

Regards

Marcin
 
Hi,

Cause they are still in the control, the binding in web do not work the
same as in windows, what you can do is this:

Set the datasource= null
Call listbox.DataBind()
this should delete all
opposite what you can do if the above does not work ( very unlikely ) is
bind it to an empty collection/array, etc

cheers,
 
Back
Top