Is there a trick to getting a SlectedIndexChanged event to fire on a DropDownlist control
No matter how I select an item this event does not fire.
I ahev checked my code, I can do even handling for any of the other controls in the form but nothing on this DropDownList.
Thansk in advance.

DropDownList SelectedIndexChanged not firing
pod Student
Have you tried getting it to work in a fresh project
1) Add a ComboBox
2) Add some list items by selecting the ComboBox, clicking on Items in the property grid, and then writing a couple of lines
2) Set the DropDownStyle to DropDownList
3) Double-click the ComboBox
4) Add in the SelectedIndexChanged event handler: MessageBox.Show("Test");
5) Run
When you select one of the items does the MessageBox show up If not, then it probably isn't your code causing the problem. If so, then in your app that isn't working, you might want to make sure that the event handler is attached to the correct ComboBox's SelectedIndexChanged event. Let me know if the above doesn't work.
Thanks,
Scott Morrison
WindowsForms PM
Microsoft Corp.
RavindraPatil
Thanks to anyone who has a potential solution.
Mr. Puzzled
Oh !!
hours of testing and i was finally able to figure this out.
I had EnableViewState turned off with my .aspx page header.
when the ViewState is not saved it reverts back to the First Item as the Selected Index. Selecting the First Item then does not trigger a SelectedIndexChange Event.
make sure EnableViewState is true both on the control and on the page.
Manpreet.
Orko
I too was experiencing what others have reported - the postback occurs, but the SelectedIndexChanged event is not called.
I think I've found a definitive cause for this and a workaround.
It seems that this event will only fire if the Value property changes. A bit of a bummer if you want different items to return the same value. (I got into this because the same timezone is called different things in different parts of the world.)
The "quick and dirty" code fragments below show the workaround
To load the list (unbound)
N = 0
While dr.Read 'dr is a DataReader
lstTimezones.Value = N.ToString & "|" & dr(0)
... additional code
N = N +1
End While
In the SelectedIndexChanged event:
ValueSplit() As String = Split(lstTimezones.SelectedValue,"|")
TimezoneCode = ValueSplit(1)
Is this an HTML thing or a Microsoft thing I'd be interested in knowing.
movertom
I had the same problem but whenI made auto postback property true, it worked
Thanks
Sree
Trent Jackson
Hi I have the similar problem w/o the event firing for dropdownlist when i pass a function at selected change event..any further help pls!
thanx
marc bichara
Hello,
I have found that when I cut a control off of a form in design view and then paste it inside another container control (eg a GroupBox) that the Handles clause of my pre-existing event code gets stripped off. Since that is at the end of the method declaration, I usually end up pulling my hair out for a while until I think to check that.
ejss06
I run into this bug occasionally. Today, I fixed it by fixing up some of the page HTML.
In my case, I had had a table nested within a table. I ended up deleting the outer table and somehow ended up with an orphan <strong> tag above my <table> tag. In the HTML window, this is underlined in red as invalid but, of course, you never see this if you are editing in Design view and just looking at that and your compiler output.
Once I deleled the bad nesting, the event fired normally.
So, start by checking your HTML.
skimj
ya Manpreet's solution works fine .............
even I was facing the same problem & enabling Viewstate Works through it..
Thanx All :-)..
Inderdeep..
_Ben_
Michael Slater
le_beluet
I also had the same prob ... now its fine..
MJian
Hi,
I had the same kind of problem. Hema's solution worked out.
Thanks,
Chakri.
Kamil Skalski
I have had and am again having this same bug of ddl SelectedIndexChanged not firing.
When I select a new value on the ddl, the page posts back, the Page_Load function is invoked as PostBack, but the Event handler is never called. I have checked the handler logic in InitializeComponent; it is fine.
Yes, Autopostback is set true.
I use this event all the time. It works on most pages with no problem.
It will not work on the current page I am on, no matter what I do.
I am working in VS, .Net Framework 1.1, developing a webform. All other controls on the webform work fine - buttons, checkboxes and datagrid select.
There are no visible HTML errors on the html page.
I have no clue what else to look at or try.
I would greatly appreciate any insight or direction on where to go to get some actual help with this.
tim