>Hi All,
>
>I have created a couple of user controls that I want to dynamically add to a page. The first issue is I was under the impression I had to set the value I wanted in my controls within the Page_PreRender as opposed to the Page_Load event. When the Page PreRender fires, my controls are still null. What is the common wisdom of when to set my controls values?
Page_Load. PreRender happens too late.
>The second question is can I place a User Control in a PlaceHolder? It doesn't throw any exceptions, but doesn't display. I need to place one of two controls in a specific location on my page and don't know which control until the data is retrieved but before the page is loaded. What is the best way to do this?
I'd think strongly about whether dynamically added controls were really necessary, or if you could just get away with putting multiple controls on the page and selectively making them visible/invisible. It can be a PITA to get the eventing correct when you add controls dynamically and it's the kind of thing you might not notice immediately. If you really think you need to go this route, I can follow up with more info (for example, you'll definitely want to use a placeholder for a dynamically added control).