Retaining viewstate of dynamic controls
-
Hi, I am currently building aproject management application. My current issue lies with a dynamic table which refreshes each time i choose a different project (from a dropdown). I used to create my controls (in the dynamic table) on PageLoad. This worked fine but however, the viewstate was retained when i chose another project eventhough i tried almost everything from EnableViewstate = false to many others... So, the quick fix was to actually create the dynamic controls in the "selectedIndexChanged" event of the project dropDown. This worked great. However, i am having a problem to updated data in one of these dynamic textboxes. If i change a value in the dynamic texbox and then click on "Save" button, i lose the viewstate of this textbox and it reverts to its previous value. Moreover, i do have dynamics dropdowns in the same table and they work fine, passing the changes. Can you please help me fix that out? Thanks beforehand dear friends. :omg: Krugger
-
Hi, I am currently building aproject management application. My current issue lies with a dynamic table which refreshes each time i choose a different project (from a dropdown). I used to create my controls (in the dynamic table) on PageLoad. This worked fine but however, the viewstate was retained when i chose another project eventhough i tried almost everything from EnableViewstate = false to many others... So, the quick fix was to actually create the dynamic controls in the "selectedIndexChanged" event of the project dropDown. This worked great. However, i am having a problem to updated data in one of these dynamic textboxes. If i change a value in the dynamic texbox and then click on "Save" button, i lose the viewstate of this textbox and it reverts to its previous value. Moreover, i do have dynamics dropdowns in the same table and they work fine, passing the changes. Can you please help me fix that out? Thanks beforehand dear friends. :omg: Krugger
whenever a control is added through controls.add() function, it goes through init,load and prerender. Add the dynamic textbox to the table or page before you set the property. this will enable the textbox to participate in the viewstate. Dim txtBox As New TextBox Table.Controls.Add(txtBox) txtBox.Text = "ABCDE" Regards John