Jump to content

DropDownList


pandabear1437

Recommended Posts

i have 3 dropdownlist 1, 2 and 3.By having each of them enabling their autopostback properties, i want to subsequently change data according to the previous dropdownlists. For example, dropdownlist2 will change in respect to dropdownlist1, and dropdownlst3 will also change in respect to dropdownlist2. However, to enable this, each of the ddl(dropdownlist) will have the SelectedIndexChange function, here is the problem. If the data binded to the ddl is only one item, then there will be chance for the function to run because to index change will take place. The selected item will always be the first item. Is there any way to overcome this contraint. Or are they any function except for the selectedindexchange?

Link to comment
Share on other sites

One solution is to have the first option in the ddl always as "Select one from list" and set the value for that as 0.this will force the user to pick some option other than thatyou can check if the user has selected some option, check ddl.selectedindex.value>0with this you can make sure that the ddl is not in "Select one from list" option and you can also get the "selectedindexchange" working

Link to comment
Share on other sites

One solution is to have the first option in the ddl always as "Select one from list" and set the value for that as 0.this will force the user to pick some option other than thatyou can check if the user has selected some option, check ddl.selectedindex.value>0with this you can make sure that the ddl is not in "Select one from list" option and you can also get the "selectedindexchange" working
Hi pulpfiction,I have tried before the solution provided by u. i insert data into ddl1 using ado.net and i load ddl1 when page load, but the problem is i have to enable ddl1 autopostback properties to enable ddl2 to change according to ddl1, but because of the autopostback properties, whenever i select an option other the option in index 0 in ddl1, it will run page load again. So the option in index 0 will always appear in ddl1 and user will not be able to select other option. However, if i put 'If Not Page.IsPostBack = True Then before the coding to insert data into ddl1, it can work but the data in ddl1 will only appear once. Is there any other way to solve this problem?Thanks.
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...