Click to See Complete Forum and Search --> : Dropdown list SelectedIndexChanged works 2nd time, not 1st


animal415
09-13-2006, 12:00 PM
Creating a website in VB.NET/ASP.NET.

this problem has been perplexing me for days. I have 2 dropdown lists. the selection made on the first one determines which XML file gets pulled in, to then populate the 2nd dropdown list. The 2nd dropdown list then determines which label becomes visible. The 2nd one works great, every time selectedindex changes on the 2nd ddl, the correct label appears. The problem is the first ddl. The first time a choice is made in it after page load, not only does it not update the 2nd ddl, but it actually goes back to the original default value. But the 2nd time its clicked it works great. And every time thereafter it works great too. Its only the first time that ddl #1 doesn't work.

To add in another clue... If I click any other control that causes a postback, such as another ddl, then the first ddl works the first time its clicked. Its like something needs to happen to get the ddl #1 primed. its so weird and frustrating.
Any help would be greatly appreciated.

sirpelidor
09-14-2006, 12:50 PM
under ur selectedindex method for your 2nd ddl, u can try force to pre-select whatever u had for the first ddl's choice.

example:

private selectedindex_ddl2(x,y){
ddl1.SelectedValue = ddl.SelectedValue;
//other code here
}

animal415
09-18-2006, 12:11 PM
Thanks for the reply sirpeldor. What actually fixed the problem was basically creating a brand new page, using all the exact same code. I just KNEW my code was good. I poured over that code for hours and couldn't find one single thing that looked odd. The solution to this problem surprised me though. I created a new page, with a new name, used all the exact same code. Works fine now.