using a variable to represent a textboxname

T

TB

Hi All:

Is it possible to to use a variable to represent a textboxname? As I have a
form with a lot of similarly named textboxes to be populated by similarly
named colums from a table, I would like to do something like this
(pseudocode):

dim i as integer

for i = 0 to 10
txtbox(i).text = row.item("field" & i).ToString()
next

If the above is possible, what would be the exact code?

Thanks

TB
 
R

Riki

TB said:
Hi All:

Is it possible to to use a variable to represent a textboxname? As I
have a form with a lot of similarly named textboxes to be populated
by similarly named colums from a table, I would like to do something
like this (pseudocode):

dim i as integer

for i = 0 to 10
txtbox(i).text = row.item("field" & i).ToString()
next

If the above is possible, what would be the exact code?

If you name your textboxes TextBox1, TextBox2, etc, you could do with

For i=0 to 10
Page.FindControl("TextBox" & i).Text = row.item("field" & i).ToString()
Next i

Enjoy the programming!
 
T

TB

Thanks a lot!

TB

Riki said:
If you name your textboxes TextBox1, TextBox2, etc, you could do with

For i=0 to 10
Page.FindControl("TextBox" & i).Text = row.item("field" &
i).ToString()
Next i

Enjoy the programming!
 

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