Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8012029
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T19:12:15+00:00 2026-06-04T19:12:15+00:00

I have 5 dropdown lists and am trying to make it so if I

  • 0

I have 5 dropdown lists and am trying to make it so if I choose a certain value on a certain dropdown list, it won’t show that specific item on the following dropdown lists.

I am doing this through a specific SQL query on each dropdown list’s data source, the code is in the following pastebin link because the StackOverflow textbox is buggy for me for some reason:
http://pastebin.com/gDm8MPrL

I’m not exactly sure why, but it isn’t displaying anything from the database. When I test a normal “SELECT *” query it works, so it isn’t a connection problem.

Could anyone give me a hand?

Thanks!

PASTED CODE FROM PASTE BIN

<asp:DropDownList ID="ddlHero1" runat="server" DataSourceID="ddlDataSource0"                        DataTextField="ChampName" DataValueField="ChamadpName" AutoPostBack="True">
</asp:DropDownList>
<asp:SqlDataSource ID="ddlDataSource0" runat="server" ConnectionString="<%$ ConnectionStrings:mobamanagerConnectionString%>" SelectCommand="SELECT [ChampName] FROM [Champions] WHERE Champname NOT IN (
SELECT [ChampName] FROM [Champions] WHERE Champname=@ddlHero2 
UNION 
SELECT [ChampName] FROM [Champions] WHERE Champname=@ddlHero3
UNION
SELECT [ChampName] FROM [Champions] WHERE Champname=@ddlHero4
UNION
SELECT [ChampName] FROM [Champions] WHERE Champname=@ddlHero5)">
   <SelectParameters>
        <asp:ControlParameter ControlID="ddlHero2" Name="ddlHero2" 
                                                PropertyName="SelectedValue" />
        <asp:ControlParameter ControlID="ddlHero3" Name="ddlHero3" 
                                                PropertyName="SelectedValue" />
        <asp:ControlParameter ControlID="ddlHero4" Name="ddlHero4" 
                                                PropertyName="SelectedValue" />
        <asp:ControlParameter ControlID="ddlHero5" Name="ddlHero5" 
                                                PropertyName="SelectedValue" />
   </SelectParameters>
</asp:SqlDataSource>

This process is repeated another 4 times with different queries for each DDL, but the procedure is identical.

EDIT: Thanks for pasting the code in, mod!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T19:12:17+00:00Added an answer on June 4, 2026 at 7:12 pm

    For your case you can do it with or without Ajax, but essentially make all the lists
    AutoPostback=”true”
    and enabled=”false” except the first and then do something like the following:
    this sample code in VB

       Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Not Page.IsPostBack Then
            'here load the first only
            'make the 2d enabled
        Else
            If ViewState("ddlHero1").ToString <> "" Then
                'get the value of the 1st from the viewstate
                'ddlHero1.selectedindex=cint(ViewState("ddlHero1").ToString)
                'make the 2nd enabled
                'bind the second
            End If
            If ViewState("ddlHero2").ToString <> "" Then
                'get the value from viewstate
                'ddlHero2.selectedindex=cint(ViewState("ddlHero2").ToString)
                'make the 3nd enabled
                'bind the 3rd
            End If
            If ViewState("ddlHero3").ToString <> "" Then
                'like the 2nd..etc
            End If
        End If
    End Sub
    

    on the SelectedIndexChanged event for each list save the selected value in the viewstate

    Protected Sub ddlHero1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ddlHero1.SelectedIndexChanged
    
        ViewState("ddlHero1") = ddlHero1.SelectedIndex.ToString
        'and the same for the other lists
    
    End Sub
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have 2 dropdown lists on my webform and using jquery trying to filter/reset
I'm trying to make radio buttons that when you have them active, it displays
I'm using Jquery 1.6. I have a dropdown list that has a bunch of
I'm new to jquery and i'm trying to make a dropdown menu list like
I'm trying to do the following: I have an input <input type=text value=red,yellow,blue id=colors
I'm trying to have three input that display a list of lodging that march
I have an application that has two dependent dropdown lists, where if the user
I have been trying to make a VBA code to do the following. I
I have created two dropdownlist, what i am trying to do is make them
I have multiple dropdown lists calculating a total price at the end, it works

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.