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