How do I retrieve dynamically created form controls in the code behind?

On my page the user can select a number from a drop down list to choose how many text boxes to fill in. So, if the user selects 8, then 8 text boxes will be dynamically created at runtime and displayed on the page. I want to get the values that the user enters in these textboxes when the "submit" button is clicked, but I don't know how many textboxes have been created prior to runtime, so I don't know how many values there are. How do I get these values in the codebehind?
LVL 2
CitySecAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

the_billCommented:
You could say, if the user has selected n from the drop down list, create controls and assign them IDs
txtDynamicBox1, up to txtDynamicBoxn.

You would then get each dynamic textbox, by going through a for loop, and use FindControl to get the textbox eg

For i as Integer = 1 to DropdownPicker.Text
Dim myTextBox as TextBox
 myTextBox = FindControl("txtDynamicBox" & i)
Next

Just ensure your code to generate the boxes isnt filtered for non-postbacks only, ie dont create the boxes in a If IsPostBack=False statement
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
darshan_derasariCommented:
Go through below links which explain concept of dynamic controls.


http://forums.asp.net/t/1186195.aspx
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.