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. Dynamic dropdown list

Dynamic dropdown list

Scheduled Pinned Locked Moved ASP.NET
tutorialcsharpasp-netcollaborationhelp
8 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.
  • I Offline
    I Offline
    isaii
    wrote on last edited by
    #1

    Hi, Can anybody send me a tutorial on how to handle a dynamic dropdownlist in vb asp.net. What I want is to have 2 dropdownlist. In my first dropdownlist, I have the list of departments. Then in my second dropdown list, I have the list of the members of each department. So if I select Human Resource in my first drop down list, members from HR team in my second dropdown list will be enumerated and so on with other department. I really appreciate your help. Thanks in advance.

    _ 1 Reply Last reply
    0
    • I isaii

      Hi, Can anybody send me a tutorial on how to handle a dynamic dropdownlist in vb asp.net. What I want is to have 2 dropdownlist. In my first dropdownlist, I have the list of departments. Then in my second dropdown list, I have the list of the members of each department. So if I select Human Resource in my first drop down list, members from HR team in my second dropdown list will be enumerated and so on with other department. I really appreciate your help. Thanks in advance.

      _ Offline
      _ Offline
      _AK_
      wrote on last edited by
      #2

      What you need to do is first fill the first dropdownlist(department) at the page load event and then on the SelectedIndexChanged fill the second dropdownlist(members) by getting the filtered records(members only associated with selected department).

      Best Regards, Apurva Kaushal

      I 1 Reply Last reply
      0
      • _ _AK_

        What you need to do is first fill the first dropdownlist(department) at the page load event and then on the SelectedIndexChanged fill the second dropdownlist(members) by getting the filtered records(members only associated with selected department).

        Best Regards, Apurva Kaushal

        I Offline
        I Offline
        isaii
        wrote on last edited by
        #3

        Thank you very much but can you show me how? Because Im a newbie with this thing. I really appreciate it. Thanks in advance.

        _ 1 Reply Last reply
        0
        • I isaii

          Thank you very much but can you show me how? Because Im a newbie with this thing. I really appreciate it. Thanks in advance.

          _ Offline
          _ Offline
          _AK_
          wrote on last edited by
          #4

          If you know how to fill a dropdown list then at load event you assign the datasource(for this first you have to get the data from database) and then call the databind method. Secondly on the selectedindex change event of the first dropdown list bind the second dropdownlist(getting the corresponding data from the database). To fill the second dropdownlist you have to pass the selected items ID(i.e. departments ID) in order to get the correct set of records. If you still have the problem can you give the case in which exactly you are having the problem?

          Best Regards, Apurva Kaushal

          K I 2 Replies Last reply
          0
          • _ _AK_

            If you know how to fill a dropdown list then at load event you assign the datasource(for this first you have to get the data from database) and then call the databind method. Secondly on the selectedindex change event of the first dropdown list bind the second dropdownlist(getting the corresponding data from the database). To fill the second dropdownlist you have to pass the selected items ID(i.e. departments ID) in order to get the correct set of records. If you still have the problem can you give the case in which exactly you are having the problem?

            Best Regards, Apurva Kaushal

            K Offline
            K Offline
            Kamran_ku
            wrote on last edited by
            #5

            I M not Getting ur point plz send me appropriat code ..

            _ 1 Reply Last reply
            0
            • K Kamran_ku

              I M not Getting ur point plz send me appropriat code ..

              _ Offline
              _ Offline
              _AK_
              wrote on last edited by
              #6

              Do you want the code to bind the dropdownlist control, if so the here[^] you can get that.

              Best Regards, Apurva Kaushal

              1 Reply Last reply
              0
              • _ _AK_

                If you know how to fill a dropdown list then at load event you assign the datasource(for this first you have to get the data from database) and then call the databind method. Secondly on the selectedindex change event of the first dropdown list bind the second dropdownlist(getting the corresponding data from the database). To fill the second dropdownlist you have to pass the selected items ID(i.e. departments ID) in order to get the correct set of records. If you still have the problem can you give the case in which exactly you are having the problem?

                Best Regards, Apurva Kaushal

                I Offline
                I Offline
                isaii
                wrote on last edited by
                #7

                Hi.. yes I already filled up a dropdown list coming from SQL data as my datasource. But I dont know how to code the second part that you are saying. "Secondly on the selectedindex change event of the first dropdown list bind the second dropdownlist(getting the corresponding data from the database). To fill the second dropdownlist you have to pass the selected items ID(i.e. departments ID) in order to get the correct set of records." Can you show me in vb.net code? I really appreciate it. Thanks.

                _ 1 Reply Last reply
                0
                • I isaii

                  Hi.. yes I already filled up a dropdown list coming from SQL data as my datasource. But I dont know how to code the second part that you are saying. "Secondly on the selectedindex change event of the first dropdown list bind the second dropdownlist(getting the corresponding data from the database). To fill the second dropdownlist you have to pass the selected items ID(i.e. departments ID) in order to get the correct set of records." Can you show me in vb.net code? I really appreciate it. Thanks.

                  _ Offline
                  _ Offline
                  _AK_
                  wrote on last edited by
                  #8

                  What you need to do in the second part is you have to get the ID value of the item selected in the department dropdownlist(when you would have bind the first dropdownlist then you would have assigned the text and value field, you need to get that value of the selected item). And once you are having that you can query to get the records associated with that department ID. And once you get the desired records you have to bind the second dropdown exactly like you have done with the first one. I think now it would have been clear. :)

                  Best Regards, Apurva Kaushal

                  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