Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Updating drop-downlist boxes corresponding to values selected in the other drop-down list

Updating drop-downlist boxes corresponding to values selected in the other drop-down list

Scheduled Pinned Locked Moved ASP.NET
databasesql-serversysadmintutorialannouncement
6 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • F Offline
    F Offline
    fasttoshiba
    wrote on last edited by
    #1

    Hi....I have two drop-down List boxes.How to update one drop-down list box based on values of other drop-down list.. E.g: Drop-down list 1 contains cars like Toyota,Hyundai etc... If Toyota is Selected (drop-down list 2 it must be updated with models of Toyota) else Hyundai is selected (drop-down list 2 must be updated with models of Hyundai) All these data must be taken from SQL server I am able to display the drop-down list 1 but i am not sure how to display only corresponding models of the selected Make(drop-down list1)

    C 1 Reply Last reply
    0
    • F fasttoshiba

      Hi....I have two drop-down List boxes.How to update one drop-down list box based on values of other drop-down list.. E.g: Drop-down list 1 contains cars like Toyota,Hyundai etc... If Toyota is Selected (drop-down list 2 it must be updated with models of Toyota) else Hyundai is selected (drop-down list 2 must be updated with models of Hyundai) All these data must be taken from SQL server I am able to display the drop-down list 1 but i am not sure how to display only corresponding models of the selected Make(drop-down list1)

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      Why is this asked so often when it's so trivial ? 1 - handle the changed event of the first list 2 - in the event, read the value, and use it to populate the second list

      Christian Graus Driven to the arms of OSX by Vista.

      F 1 Reply Last reply
      0
      • C Christian Graus

        Why is this asked so often when it's so trivial ? 1 - handle the changed event of the first list 2 - in the event, read the value, and use it to populate the second list

        Christian Graus Driven to the arms of OSX by Vista.

        F Offline
        F Offline
        fasttoshiba
        wrote on last edited by
        #3

        I asked this because i am unable to pass the values.....can u provide me with an example.... I am not sure of how to pass the Make value to database inorder to get the Model..... Give me one example

        C 1 Reply Last reply
        0
        • F fasttoshiba

          I asked this because i am unable to pass the values.....can u provide me with an example.... I am not sure of how to pass the Make value to database inorder to get the Model..... Give me one example

          C Offline
          C Offline
          Christian Graus
          wrote on last edited by
          #4

          Well, typically, there is an id stored as a value for the first list, so you end up with something like select * from model where makeID = @makeId as a stored proc which you call using the id from the selected column.

          Christian Graus Driven to the arms of OSX by Vista.

          R 1 Reply Last reply
          0
          • C Christian Graus

            Well, typically, there is an id stored as a value for the first list, so you end up with something like select * from model where makeID = @makeId as a stored proc which you call using the id from the selected column.

            Christian Graus Driven to the arms of OSX by Vista.

            R Offline
            R Offline
            Ranjit Viswakumar
            wrote on last edited by
            #5

            This can also be done with AJAX. You have the user-facing page, an AJAX script, and a dynamic page. The user's selection passes a value over an XmlHttp request to a dynamic page, the output is returned via XmlHttp, and the contents of the user-facing page are changed via Javascript. Check out this example which has samples of all three parts- http://w3schools.com/ajax/ajax_database.asp[^] Good luck! Ranjit Viswakumar Professional Services Specialist HostMySite.com[^]

            C 1 Reply Last reply
            0
            • R Ranjit Viswakumar

              This can also be done with AJAX. You have the user-facing page, an AJAX script, and a dynamic page. The user's selection passes a value over an XmlHttp request to a dynamic page, the output is returned via XmlHttp, and the contents of the user-facing page are changed via Javascript. Check out this example which has samples of all three parts- http://w3schools.com/ajax/ajax_database.asp[^] Good luck! Ranjit Viswakumar Professional Services Specialist HostMySite.com[^]

              C Offline
              C Offline
              Christian Graus
              wrote on last edited by
              #6

              Sure - it's almost the canonical AJAX example. I was just trying not to confuse the guy tho.

              Christian Graus Driven to the arms of OSX by Vista.

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups