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. Adding Combo Boxes to a Web Form Dynamically

Adding Combo Boxes to a Web Form Dynamically

Scheduled Pinned Locked Moved ASP.NET
data-structurestutoriallearning
4 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.
  • J Offline
    J Offline
    jcrussell
    wrote on last edited by
    #1

    Anyone ever tried to add combo boxes to a webform dynamically We have a heirachy (tree) we need to implement where each level’s choice are determined by the previous levels choice. i.e. (and this is a trival example) Choose a country Based on the country choose a state Based on the state choose a suburb Based on the suburb choose a street e.t.c. e.t.c. And of course the number of levels is dynamic :~ And even better – each branch could be a differnet length (i.e. Might only have States for Australia but have States and suburbs for germany) Basically I need to add a new combo box after they have chosen from “country” that gives them the list of available “states” and so on PLUS when they change country – I need to clear all the invalid combos I have played around with this for ages – but keep tying myself in knots There are a number of problems A) I don’t know the changed value in page load (have to wait for the onchnage event handler) B) I cant add controls to my page in the event handler – as they don’t get rendered until next postback Any Suggestions will be GREATLY appreciated I have a headache :~ /jason

    V 1 Reply Last reply
    0
    • J jcrussell

      Anyone ever tried to add combo boxes to a webform dynamically We have a heirachy (tree) we need to implement where each level’s choice are determined by the previous levels choice. i.e. (and this is a trival example) Choose a country Based on the country choose a state Based on the state choose a suburb Based on the suburb choose a street e.t.c. e.t.c. And of course the number of levels is dynamic :~ And even better – each branch could be a differnet length (i.e. Might only have States for Australia but have States and suburbs for germany) Basically I need to add a new combo box after they have chosen from “country” that gives them the list of available “states” and so on PLUS when they change country – I need to clear all the invalid combos I have played around with this for ages – but keep tying myself in knots There are a number of problems A) I don’t know the changed value in page load (have to wait for the onchnage event handler) B) I cant add controls to my page in the event handler – as they don’t get rendered until next postback Any Suggestions will be GREATLY appreciated I have a headache :~ /jason

      V Offline
      V Offline
      V 0
      wrote on last edited by
      #2

      Controls.Add(...); ?? good luck. (note if you do this it could be you have to manually adapt the color, position, size etc of the inserted control...) hope this helps. No hurries, no worries.

      P 1 Reply Last reply
      0
      • V V 0

        Controls.Add(...); ?? good luck. (note if you do this it could be you have to manually adapt the color, position, size etc of the inserted control...) hope this helps. No hurries, no worries.

        P Offline
        P Offline
        PerthCoder
        wrote on last edited by
        #3

        Ummm, that isn't really the problem. We are already adding the controls to the page. The issue is that when a selection is made in one combo box, we need to add another one and populate it based on the value from the previous one. To further complicate the issue, if a combo box further up the "tree" is changed then we need to clear all subsequent combos and add a new one based on the new selection. /chris

        V 1 Reply Last reply
        0
        • P PerthCoder

          Ummm, that isn't really the problem. We are already adding the controls to the page. The issue is that when a selection is made in one combo box, we need to add another one and populate it based on the value from the previous one. To further complicate the issue, if a combo box further up the "tree" is changed then we need to clear all subsequent combos and add a new one based on the new selection. /chris

          V Offline
          V Offline
          V 0
          wrote on last edited by
          #4

          Do it in the eventhandler? But I can see it isn't that easy ...(lifecycle is a b*tch :^) ) anyway good luck. No hurries, no worries.

          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