One item dropdowns

J

Jon

I am using cascading dropdowns, where one dropdown determines the data in
the next, etc...

If a dropdown has only one item in it, the SelectedIndexChanged event is
never fired, even if you click on the dropdown and "reselect" the single
item. This also happens when there are multiple items in the DD with the
first item. You have to select another list item, then reselect the first
one to have the event fire. I have it set to AutoPostBack, but obviously it
is not in these situations. Is there a way to make the event happen in
these situations.

I tried the following (thinking it would force the user to select the item
and fire the event), but it still selected the single item.

ddTest.DataBind()
ddTest.SelectedIndex = -1

Thanks
 
K

Kevin Spencer

Try adding a "-- Select Item --" item to the top of the list. That way,
selecting even the only ONE (other) item in the dropdown causes a
selectedIndex changed event.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Neither a follower
nor a lender be.
 
M

Martin Eyles

Just thinking about this. Forgive me if this is a silly idea, but here goes.
I get the impression that you don't want the "-- Select Item --" to show in
the dropdown list. I would suggest including it as suggested, but setting
the style atrribute to "visibility: hidden; height:0; width:0"

ME
 

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,780
Messages
2,569,611
Members
45,281
Latest member
Pedroaciny

Latest Threads

Top