How can i get data from dynamically added html controls?

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?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,900
Latest member
Nell636132

Latest Threads

Top