Dynamic controls created on Button click get cleared on PostBack in ASP.Net

Last Reply on Jun 15, 2013 10:44 AM By Mudassar

Posted on Jun 15, 2013 07:31 AM


I have created a web form in which i have used user control

there is link  button on different link button user control loads . i have added dynamically webcontrol to that link button .

they are loading properly but when i try to save data through one of user control on click of button the user control disapper from that place

but when i put static user control to my page its working

You are viewing reply posted by: Mudassar on Jun 15, 2013 10:44 AM.
Posted on Jun 15, 2013 10:44 AM

When using Dynamic controls you need to recreate it always otherwise they are removed.

Thus on Submit button again Add the UserControl.

And easier way would be to simply keep it static make UserControl Visible on LinkButton click, it will make it easier for you to manage