DropDownList
control is returning the wrong item.
My code performs a specific action with the SelectedItem
when DropDownList.SelectedValue = -1
.
When testing the code, I pick item A
at index = 2
. The resulting DropDownList.SelectedItem = "A"
. Good so far.
But I pick item B
at index = 3
. The resulting DropDownList.SelectedItem = "A"
. According to the debugger, DropDownList.SelectedIndex = 2
in both cases.
What causes the SelectedIndex
to always take on the same value?
Note: When I pick items C
through Z
, they return the proper SelectedText
and SelectedIndex
.
if(Int32.Parse(dropdown.SelectedValue).Equals(-1))
{
// Do something with the selected item
DoThis(dropdown.SelectedItem.ToString());
}