954,514 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Accessing data from Dynamically created textboxes

I have a project where the user has to input a range of questions along with the question numbers. (So the number of questions is not fixed.) I am using a panel where i am adding the dynamically created textboxes. The textboxes are created with the user clicks an image button.
So far so good.
now i want to store the questions entered by the user in a databaase, how can i achieve this?
Also if the user creates and enters the data in the textbox, and later when he returns, i wld like to show the data previuosly entered by him, how can i achive this?
Thank in advance

C#Novice
Newbie Poster
11 posts since Aug 2007
Reputation Points: 10
Solved Threads: 0
 

set the Name property of the textboxes to a common name and increment with numbers, for example, "txtQuestion1", "txtQuestion2", etc.

Then later you can iterate through the Controls collection (through the Form or whatever is holding the textboxes) and if the name starts with "txtQuestion" for example, take it's Text value and store it.

To load the values just do the process backwards, setting the Text property to "txtQuestion" boxes (or as you create them).

Hope that helps a bit

vckicks
Junior Poster in Training
58 posts since Jun 2008
Reputation Points: 11
Solved Threads: 9
 

Hi, Also try DataGridView Control to add the Questions and Answer.

selvaganapathy
Posting Pro
547 posts since Feb 2008
Reputation Points: 44
Solved Threads: 100
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You