1
votes

I have a drop down list that is populated based on the selected value of another drop down list. The main drop down list is dlJobName. It contains the list of all active jobs. The second drop down list is dlStage. This contains the distinct stage values related to the JobName. Here is the query that populates the dlStage drop down list.

SELECT DISTINCT [AnnotationDate] as Annotation_Date FROM [vw_GridviewSource] WHERE ([Name] = @Name)

In this code the AnnotationDate is not a date field but a text field. @Name is a variable equal to the selected value from the dlJobName list.

Here is my dilemma. When I make a selected_index_change event for the dlJobName, before I update the gridview that uses both of these drop down lists, I need to update the dlStage to only available values. What is happening is the dlStage list is not updated and the values in the drop down list is not available for the new JobName. Is there a way to force the query to run on the dlStage drop down list in conjunction with the selected index change event? This would cause the gridview to at least populate and not error out.

I can provide whatever additional code is necessary.

3

3 Answers

0
votes

I think you have not set AutoPostBack="true" of drop down list. If Problem continues please put your HTML and cs code for proper help.

0
votes

Hi maybe like other user comment you need go to property from dropdownlist, search AutoPostBack and change False for True. Don't forget clean firsr your dropdownlist

DropDownList.Items.Clear() (VB.NET) DropDownList.Items.Clear(); (C#)

After clean your dropdownlist charge again your method to bind dropdownlist

0
votes

set the property
dlJobName.AutoPostBack="true"
This will makes the SelectedIndexEvent to fired when the selected index of the main dropdown is changed.
In that selectedIndexChanged Event load the second DropdownList. Here is an example,
http://asp-net-example.blogspot.in/2009/03/how-to-use-dropdownlist-autopostback.html
Hope your problem solved, if still exists kindly paste your snippet.