Equivalent for Eval function

G

gogaz

Hello there,

I have a form with nine textboxes named as txt1, txt2, txt3.....txt9.
I would like to populate these boxes with values from database.

how can i do this in Page_load sub?

i mean in client side javascript, u can use eval function like :-
for(i=1;i<10;i++)
{
eval('document.forms[0].txt'+i+'.value=arrVals['+i+']');
//arrVals is an array with 9 different values
}

well i acheived wat i wanted eventually by writing/creating a client
side array in a while dr.read() loop in page_load sub. and then
executing above javascript.

but i would like to know if there is a similar approach on serverside
asp.net/vb.net? if no, then why??

thanx in advance!
 
P

Patrice

You could use FindControl to find these controls in the control tree or
browse directly the Controls collection of their parent objet...

Patrice
 
G

Guest

As always there are many ways to skin a cat but one approach would be create an enumerator from the page object and loop through the controls using the enumerator assigning values as you go.
 
T

TJS

vb.net dropped the eval and execute commands


Patrice said:
You could use FindControl to find these controls in the control tree or
browse directly the Controls collection of their parent objet...

Patrice


gogaz said:
Hello there,

I have a form with nine textboxes named as txt1, txt2, txt3.....txt9.
I would like to populate these boxes with values from database.

how can i do this in Page_load sub?

i mean in client side javascript, u can use eval function like :-
for(i=1;i<10;i++)
{
eval('document.forms[0].txt'+i+'.value=arrVals['+i+']');
//arrVals is an array with 9 different values
}

well i acheived wat i wanted eventually by writing/creating a client
side array in a while dr.read() loop in page_load sub. and then
executing above javascript.

but i would like to know if there is a similar approach on serverside
asp.net/vb.net? if no, then why??

thanx in advance!
 

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

Top