Capturing Data of Dynamically Created TextBox's

J

Jack Johnston

Hi there,

I am dynamically created a table at runtime on an aspx form. The last
cell of each row contains a TextBox in which the user will enter
numeric values into.

Each textbox I create is given a name such as myTextBox0, myTextBox1,
... etc Basically the index of the loop that creates the table is
appended to the end of each TextBox name (ID).

My Problem:

How do I capture the values in each text box once the user continues
(click button) to the next screen??

If you could possibily post me an example of how to do this I would be
most grateful.

Thanks in advance.
 
N

Natty Gur

how do you move to the next page ?
if you use Server.Transfer you can use the Form collection:
Form["myTextBox0"]

Natty Gur, CTO
Dao2Com Ltd.
28th Baruch Hirsch st. Bnei-Brak
Israel , 51114

Phone Numbers:
Office: +972-(0)3-5786668
Fax: +972-(0)3-5703475
Mobile: +972-(0)58-888377

Know the overall picture
 
J

John Johnston

No I just have a button and within the button event I attempt to capture
the values. Can you please be more specific?
 
N

Natty Gur

On the same page ? by using the controls ID (just dont forget to
recreate them on post back) and the FindControl method :

string x = ((TextBox)this.FindControl("mytextbox1")).Text;



Natty Gur, CTO
Dao2Com Ltd.
28th Baruch Hirsch st. Bnei-Brak
Israel , 51114

Phone Numbers:
Office: +972-(0)3-5786668
Fax: +972-(0)3-5703475
Mobile: +972-(0)58-888377

Know the overall picture
 
J

John Johnston

but on postback isn't everything recreated? so the values within the
text box will be wiped?
 
N

Natty Gur

Yes, every thing recreated but the asp.net smart enough to change the
text box value to the value submitted from the client.

Natty Gur, CTO
Dao2Com Ltd.
28th Baruch Hirsch st. Bnei-Brak
Israel , 51114

Phone Numbers:
Office: +972-(0)3-5786668
Fax: +972-(0)3-5703475
Mobile: +972-(0)58-888377

Know the overall picture
 

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

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top