Link to home
Start Free TrialLog in
Avatar of Peter Drespel
Peter Drespel

asked on

How to loop through all the text controls on the web form and store the value in an array

I have a web form with has two dropdown list items. But at run time, I dynamically add the 5 text box controls to the form.

Now I want to read the data entered in these 5 text boxes into an array so that I could then loop through the array to save it to the SQL server table.

I am proficient in VB and request a sample VB code that handles my request.

Thank you all in advance.
Avatar of Glen Richmond
Glen Richmond
Flag of United Kingdom of Great Britain and Northern Ireland image

as its only 5 objects why not address them directly?

MyArray(1)=myObject1.Text
MyArray(2)=myObject2.Text
MyArray(3)=myObject3.Text
MyArray(4)=myObject4.Text
MyArray(5)=myObject5.Text
Avatar of Peter Drespel
Peter Drespel

ASKER

To further explain, I wish to let you know that the 5 objects that are created at run time are read from a table. The table hold the name of the control and the label that it should display.

For eg.

ID, CONTROL_NAME, CONTROL_LABEL, FORM_ID
1,'Customer_ID','Customer ID',1
2,'Customer_Name','Customer Name' ,1
3,'Customer_ID','Customer ID',2
4,'Customer_Name','Customer Name' ,2
5,'Amount','Amount',2

etc

So I read the database to paint the html for the web form.  The controls are not fixed, it depends on the rows in the table.

Now how can i assign myObject1.text since the myobject1 in my form_id=1 is Customer_id
ASKER CERTIFIED SOLUTION
Avatar of Glen Richmond
Glen Richmond
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial