Last post Jul 07, 2008 06:47 PM by Peter Bucher
Jul 07, 2008 06:03 PM|csdietrich|LINK
I am trying to create a highly dynamic control. Here is the setup:
Label Textbox Validator
The key with this setup is that depending on the selection that is made in the DropDownList the order that the controls below it will change. I had this all setup in a Custom Server Control, but it doesn't work. Sadly I get the following error:
I did some
reasearch and it seems that if your control is being dynamically added it should be added to the end of the controls collection. The problem I see with my implementation is that all of the controls (except the dropdownlist) can be added in any order.
I am wondering how other people have created highly dynamic like this before. Is there some trick?
Jul 07, 2008 06:46 PM|csdietrich|LINK
Ok, so I may have solved the relatively quickly. Basically, I ensured that in CreateChildControls I rewire the controls exactly the way they were from before. Then later on in the dropdownlist event handler I call Controls.Clear() and reassemble the controls
in a new order. It seems to work.
Jul 07, 2008 06:47 PM|Peter Bucher|LINK
What`s about get rid of Viewstate for your dynamic controls (TextBox and Label).
edit: Oh, thats fine :)