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