For Programmers: Free Programming Magazines  


Home > Archive > C# > May 2005 > Loop Through TextBoxes..please help









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Loop Through TextBoxes..please help
syukna

2005-05-12, 4:13 pm

I'm looking for a way to loop through all of the textboxes on a webform. Basically an easy way to do something like this:

oInsertNVC.Add(Label0.Text, TextBox0.Text);
oInsertNVC.Add(Label1.Text, TextBox1.Text);
oInsertNVC.Add(Label2.Text, TextBox2.Text);
oInsertNVC.Add(Label3.Text, TextBox3.Text);
oInsertNVC.Add(Label4.Text, TextBox4.Text);
oInsertNVC.Add(Label5.Text, TextBox5.Text);
oInsertNVC.Add(Label6.Text, TextBox6.Text);
oInsertNVC.Add(Label7.Text, TextBox7.Text);
oInsertNVC.Add(Label8.Text, TextBox8.Text);
oInsertNVC.Add(Label9.Text, TextBox9.Text);
oInsertNVC.Add(Label10.Text, TextBox10.Text);
oInsertNVC.Add(Label11.Text, TextBox11.Text);

Instead of having to hardcode each label i want to do it dynamically depending on the amount of textboxes in the form.

I tried a for..loop with something similar to Add(Label[i].Text)
It did not work though. Any ideas?

thanks for the help

-seth
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com