First Item in DropDownList does not fire OnSelectedIndexChanged

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
 
N

Norman Yuan

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.
 
G

Guest

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.
 
G

Guest

How could I add this dummy item to a ddl that has already been populated with
records from my db?

thanks,
glenn
 
J

Jeff Dillon

SELECT "Add a company", -1
UNION ALL
SELECT CompanyName, CompanyID From Companies
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,817
Latest member
DicWeils

Latest Threads

Top