I am creating a questionnaire in a gridview. The questions, answer options and answer control are under CMS. So I am building the questionnaire 'on the fly' adding controls to the page dynamically.
In Page_Load during !Page.IsPostback I bind the question text to the gridview then have another method that iterates through the gridview rows, and adds the controls to a cell eg.gvr.Cells.Controls.Add(rbl); The page renders correctly - I see all questions, answers and answer control eg, DropDownList, RadioButtonList, TextBox etc.
The problem is when I try to save the selected options, FindControl cannot find the controls. Even though when I view source I can see all ctrls and ids. I've seen a lot of posts about this issue and CreateChildControl, EnsureChildControl seem to be the route to take. But I don't unserstand how to use them. Can anyone point me to a good example?
And if anyone can explain why it is not working. The page 'looks' to be rendering correctly. Why then are the controls not being found on the postback? Are the controls not being added to the ViewState?
View Complete Post