Combo Box Junk

  • Thread starter Thread starter A
  • Start date Start date
A

A

I have a combo box that is databound to an ArrayList (IList to be more
exact)

I have a situation where if the user cancels a save I want the combo value
to go back to blank. This should be SIMPLE.

I have set the SelectedIndex to -1
I have set the SelectedValue to any option under the sun
I have set the every other known property to a value that would clear the
currently selected option.

All efforts only put the item above the currently selected item in the box.

For instance, if I have 2 items A and B in my combo and the user chooses A,
setting the SelectedIndex to -1 does the right thing--clears the combo box.
If the user chooses B setting the SelectedIndex to -1 puts A in the box.

Someone, please, enlighten me?
 
By default, when you databind a dropdownlist, there is no "blank" value. All
SelectedIndex = -1 does is tell it that there is not selected item. What you
need to do is something like this:

DropDownList.Items.AddAt(0, new ListItem("",""));
That should pop the blank item at the top of the dropdownlist.

HTH,

Bill P.
 
Yeah,

I tried this when I was bound to a DataTable and it threw errors all over,
but I will try again now that I am on an IList

Thanks
 
Back
Top