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. DropDownList Creation

DropDownList Creation

Scheduled Pinned Locked Moved ASP.NET
helpcsharptutorialquestion
4 Posts 2 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.
  • K Offline
    K Offline
    kontax
    wrote on last edited by
    #1

    hi, i'm posting because i have a problem i can't manage to solve... i have a page with a row of DropDownLists, and what i want to do is this: when the user selects a value from one of the dropdowns , a new one is created under the selected, with the same values of the previous one, except for the selected one. i know i have to write a function in c# called from OnSelectedIndexChange, but i can't understand how to create the new ddl from the code.. can anyone one help me or suggest a better way to do that? i'm working on Visual web Developer using C# thanks anyway, and sorry for the poor english.. bye Kontax

    M 1 Reply Last reply
    0
    • K kontax

      hi, i'm posting because i have a problem i can't manage to solve... i have a page with a row of DropDownLists, and what i want to do is this: when the user selects a value from one of the dropdowns , a new one is created under the selected, with the same values of the previous one, except for the selected one. i know i have to write a function in c# called from OnSelectedIndexChange, but i can't understand how to create the new ddl from the code.. can anyone one help me or suggest a better way to do that? i'm working on Visual web Developer using C# thanks anyway, and sorry for the poor english.. bye Kontax

      M Offline
      M Offline
      Mark J Miller
      wrote on last edited by
      #2

      If the second drop down has all the same value, minus the one selected you should be using a multi-select box instead of a select drop down. Then the user can select multiple choices w/o going back and forth between the server and w/o the complexity you're talking about. If you're doing this to limit the number of choices the user makes, you could do this in javascript. Then on the server-side, validate the data a second time to make sure the user didn't try and bypass your client-side script.

      Mark's blog: developMENTALmadness.blogspot.com

      K 1 Reply Last reply
      0
      • M Mark J Miller

        If the second drop down has all the same value, minus the one selected you should be using a multi-select box instead of a select drop down. Then the user can select multiple choices w/o going back and forth between the server and w/o the complexity you're talking about. If you're doing this to limit the number of choices the user makes, you could do this in javascript. Then on the server-side, validate the data a second time to make sure the user didn't try and bypass your client-side script.

        Mark's blog: developMENTALmadness.blogspot.com

        K Offline
        K Offline
        kontax
        wrote on last edited by
        #3

        Yes, the second one should have the same values except for the previously selected one. The problem is that after the first selection made with the DropDownList, the user can chose, for the selected value, properties from another DDL, and then another value for this one. So, when the user opens the page, he see a row of DDL. I need that, after the row he finish fulling it, another raw is created under the existing one, and so on, and only the mix of choises done before couldnt be re-done after... That's the reason why I can't use a multi-select box.. I hope I explaned it well.. About javascript:i'm not used to it, do you really think I can do what I need better using javascript? how could i do it? Thanks anyway for the reply :-D

        M 1 Reply Last reply
        0
        • K kontax

          Yes, the second one should have the same values except for the previously selected one. The problem is that after the first selection made with the DropDownList, the user can chose, for the selected value, properties from another DDL, and then another value for this one. So, when the user opens the page, he see a row of DDL. I need that, after the row he finish fulling it, another raw is created under the existing one, and so on, and only the mix of choises done before couldnt be re-done after... That's the reason why I can't use a multi-select box.. I hope I explaned it well.. About javascript:i'm not used to it, do you really think I can do what I need better using javascript? how could i do it? Thanks anyway for the reply :-D

          M Offline
          M Offline
          Mark J Miller
          wrote on last edited by
          #4

          Sounds like I didn't understand what it is you are trying to do. To clarify, it sounds like you are trying to allow the user to fill out a row of DDL. And then AFTER they have completed that row you want to give them a new row of DDL controls, minus the value(s) from the previous row. If this is the case, then I recommend that when the user has completed the current row you will allow them to submit those changes to the server. You could use the SelectedIndexChanged of the last DDL of the row, or a command button. When the user submits the selected values, create a new row in your data source and then rebind your Grid or list (whichever you are using) with the updated data source. Here's an blog post on using the GridView's footer template to insert new rows: http://geekswithblogs.net/casualjim/articles/51360.aspx[^]. Just put all your DDLs into the footer row and proceed as I recommended above. If your data source isn't meant to actually update a database or some other persisted store, but is just transient form data for some operation then instead of updating a persisted store you can maintain the data source in a session variable until the user has completed their operation. Then clear out the session variable when you are done.

          Mark's blog: developMENTALmadness.blogspot.com

          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