DataBinding question (Add an empty string in a ComboBox)

  • Thread starter Thread starter Sébastien
  • Start date Start date
S

Sébastien

Hi,

I would like to know if there is any was to add an empty string in a
ComboBox when that ComboBox is linked on a DataSet to display list of
values.

I tryed to create a new ComboBox control and overrides SetItemsCore function
to add an empty string (" ") to items list. I get an error message saying I
can't add data to this list.

Then I tryed to create a new ArrayList object and I just added an empty
string to it. Then I send it to my parent calling
MyBase.SetItemsCore(myArray), but It still show me the DataSource datas.

I used a breakpoint to be sure this function was entered :
Protected Overrides Sub SetItemsCore(ByVal items As
System.Collections.IList)

So if anyone have an idea, I would like to hear about it.

Thank you.
 
Just add an item after the DataBind();

i.e.
oList.DataBind();
oList.Items.Add(new ListItem(""));
 
No, I just want to add an empty string in my list without adding it to the
DataSet. I'll sort the list with a dataview so the empty string will be on
top and will allow user to not choose anything in the list.
 
It don't work cause when I set the DataSource property of my ComboBox to a
DataSet or a DataTable, I can't add anything in the list with the Add
method. That's why I did a new ComboBox class to try to override the
SetItemsCore function. I had success with no binding, but not when I am
using databinding.
 
Back
Top