I’m running into a minor issue with some ASP.Net code I’m working on. For simplicity sake lets say I have two dropdownlists, one that is full of various items and another that is full of other items, but based off the selected item of the first dropdownlist. I currently set variables into hidden inputs to check to see if the item in the first dropdownlist has changed and if it has to change the second dropdownlist, but I’m also having to check to make sure that if something else causes a postback to NOT repopulate the second dropdownlist as to not lose what is currently selected by the user. This check also allows me to make sure that when I navigate away from the page, the correct values are selected and not something replaced by a postback repopulation.
I’m new to ASP.Net/HTML/CSS/Javascript and the like. I know while what I have works, it isn’t even close to being the correct way to do things. Please help me correct my ways and figure out the BEST way to solve this current problem. Some good ASP.Net tutorial websites would be nice too as I need to keep improving my skills with it.
Try autopostback true with the selected index changed event:
And have the event populate the second dropdown:
EDIT
Well if you need it to populate from first page load you could do the following, or better still make a method which is called from both page load and selected index changed which will populate your dropdown.