First Item in DropDownList does not fire OnSelectedIndexChanged

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi folks,

If I want to select the first item in a DropDownList, I need to first select
any item other than the first item and then next I select the first item
which will then fire an event saying that I clicked the first item.

Why can't I just select the first item to get an event to fire without
having to first select any other item.

Thanks for any tips.
glenn
 
Well, if the first item is already displayed in the dropdown list, you, of
course can still click the dropdown to pop up the list and reselect the
first item. However, the SelectedIndex remains unchanged, therefore not
SelectedIndexChanged (notice the event name) event fires. If you have to do
something even the SelectedIndex is not changed, you have to design your own
way to triger the posting back and get the dropdown's SelectedIndex value on
the server and do something accordingly.
 
For example you could add an extra blank or dummy item to your list and have
that be the defulat slected item. That way as soo as a user selects a valid
item it will always have changed from the original item.
 
How could I add this dummy item to a ddl that has already been populated with
records from my db?

thanks,
glenn
 
Back
Top