Evaluating form controls in c#

Joined
Sep 12, 2006
Messages
3
Reaction score
0
I have a bunch of text boxes that are labelled

name_1
name_2
etc

Rather than doing name_1.Text = "blah"

I want to have it in a loop like so

for(i=0 etc) {
"name_" + i.Text = "blah"
}

Is this possible?
 
Joined
Sep 12, 2006
Messages
3
Reaction score
0
I have tried using Eval which didnt work, has anyone else tried this? Thanks
 
Joined
Sep 12, 2006
Messages
3
Reaction score
0
Figured it out, for anyone else...


for (int i = 1; i <= 8; i++)
{

TextBox name_tb = myForm.FindControl("name_" + i) as TextBox;
name_tb.Text = "blah";

}
 

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

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top