atrljoe
atrljoe

Reputation: 8151

Dynamic Drop Down List ASP.net

How can I create a dynamic drop down list without using AutoPostBack. I ask because I just want to change the value of what the second drop down list displays and then the user clicks a button and it submits. But If I use AutoPostBack then it postbacks to page and runs code that shouldn't be run until that final box has been selected. (I use Postback in the other part of my program so using !IsPostBack isnt a option.) I looked at Javascript but ASP generates all of its controls names at runtime. What can I do? I have looked at the Ajax CascadingDropDown control but my problem with that is it contained in a XML file or a Database, I need this to be contained inside my Page. Any Ideas?

Upvotes: 2

Views: 1929

Answers (3)

Grant Winney
Grant Winney

Reputation: 66439

Maybe this example will help? It's part of the ASP.NET AJAX Control Toolkit available here.

Upvotes: 2

MikeM
MikeM

Reputation: 27405

You can use the CascadingDropDown control from the AJAX Control Toolkit

Upvotes: 2

FishBasketGordo
FishBasketGordo

Reputation: 23132

You can use AJAX to get the values for the second drop down list, based on the selected value of the first. Add a onchange event handler on the client-side to the first drop down list that makes the AJAX call and fills the second on success.

Upvotes: 0

Related Questions