How can i get data from dynamically added html controls?

  • Thread starter Thread starter Jeff H.
  • Start date Start date
J

Jeff H.

I created a survey page with dynamically added html controls, as below.

However, now that I have the page, is there a way to reference the fields to
get the data out?

while (drResultList.Read())
{
...
// Survey question text
System.Web.UI.HtmlControls.HtmlGenericControl hQuestion = new
HtmlGenericControl();
hQuestion.TagName = "div";
hQuestion.InnerText = (string)drResultList.GetValue(1).ToString();
hQuestion.ID = "Question_" + nItem.ToString();
phSurveyText.Controls.Add (hQuestion);

// Survey answer text
System.Web.UI.HtmlControls.HtmlInputText hAnswer = new HtmlInputText();
hAnswer.ID = "Answer_" + nItem.ToString();
phSurveyText.Controls.Add (hAnswer);
...

The resulting HTML looks like this:

<div id="Question_1">Do any ....?</div>
<input name="Answer_1" id="Answer_1" type="text" />

Any suggestions greatly appreciated!

Is there a "Request.??" I could use?
 
Back
Top