This code is scaled down a bit but the important points are there:
Main Topics
Browse All TopicsI am dynamically loading a usercontrol into a panel. The usercontrol contains a few textboxes and a button - that runs a linq query to insert data in a database. I set a breakpoint on the first line of the button click event and run the code. When I click the button, the user control disappears and the breakpoint is never hit. What am I doing wrong?
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
I see how you are loading the control, but I do not see where you are loading the control. What is happening is that you are loading the control via a button click or on page load, but since you do not handle viewstate in the control, then you would have to re-add the control on page load again. So in order to do this you would have to store how many controls you have dynamically added to the page in the Viewstate collection then, at page load after a post back (button click) check if (Page.IsPostback) then iterate through the Viewstate collection variable you stored how many controls where added, and add them to the page again the same way you are doing here, basically you'll have the code you used for adding the controls in two different places (1. the place in which you add the controls originally, 2. Page load after a post back). This is the simplest way of solving your problem.
In the technical side, use this forum thread in order to give you some direction.
http://forums.asp.net/p/11
Business Accounts
Answer for Membership
by: siancellPosted on 2009-03-06 at 18:51:48ID: 23822907
You have to re-add the control again at page_load. Can you specify some of your code?