views:

92

answers:

1

Hi,

I have created a questionnaire in C# and when the user has entered their responses I want to capture the answers and save to the database.

I am building the content in codebehind and putting it into a placeholder on the page.

I can get a handle on the placeholder

PlaceHolder a = (PlaceHolder)FindControl("PlaceHolder1");

But when I then try to access the textboxes within the placeholder it says it has no controls!

Any help would be appreciated

Thanks Richard

+3  A: 

You're going to need to rebuild your dynamic control structure every page request.

The server can build all the static control structures based off of your ASPX, and then fill their values from the posted data. Since you added your own additional controls, though, you have to re-add them if you want to find their values again.

JustLoren
Hi,Thanks for your reply.The process is as follows - I create the whole page in the codebehind, then when the user has entered his responses he hits the add button. In the click event I am trying to capture the values but I can't seem to get at them using the findcontrol. If I add a label to the placeholder in the aspx file it says it has one control in it but it doesn't seem to recognise the fact that I have dynamically added a further 20+ controls.Thanks in advanceRichard
Richard
When do you add the 20+ controls? Inside which event?
JustLoren