Dynamic Controls Problem
-
I am working with ASP.NET 2.0 and am haveing a hard time trying to add controls with a button click. Here is my scenerio. I have a panel runat= server on a form page. I have a Web user control that consists of about 8 text boxes and drop downs. At design time I add 4 controls to the page. Each control represents a row. Now If I need more rows I click the button and do this in my code.
this.divServiceDetails.Controls.Add(Page.LoadControl("UserControls/ServiceDetails.ascx"));
A new control gets added to my form no problem. When I try to add another it does not add another once I have already done it once. Can some tell me how to correct this problem or offer alternative method. Thanks -- modified at 21:41 Wednesday 30th November, 2005 -
I am working with ASP.NET 2.0 and am haveing a hard time trying to add controls with a button click. Here is my scenerio. I have a panel runat= server on a form page. I have a Web user control that consists of about 8 text boxes and drop downs. At design time I add 4 controls to the page. Each control represents a row. Now If I need more rows I click the button and do this in my code.
this.divServiceDetails.Controls.Add(Page.LoadControl("UserControls/ServiceDetails.ascx"));
A new control gets added to my form no problem. When I try to add another it does not add another once I have already done it once. Can some tell me how to correct this problem or offer alternative method. Thanks -- modified at 21:41 Wednesday 30th November, 2005When we add controls at runtime they got added but after postback they lost i.e in panel each time new control is added and earlier one get lost well u can try to use a variable which increment each time u click to add and in loop base on variable add no of rows each time. It is just an hit and trial.