dynamic html table with textboxes

M

Michael Meckelein

Environment: VS.NET 2003
Application: ASP.NET web application
Program language: C# (Csharp)

Situation:
I get some information from a sql database. With this information I generate
a html table "myHtmlTable" dynamically. For each data row I added an
additional column. In the additional column is a textbox called
"textbox(rowcount)". In my webpage (.aspx) I have a PlaceHolder (myPH). The
generated html table is added to this PlaceHolder:
myPH.Controls.Add(myHtmlTable);

Now I have a problem. If the user enter some text in the textbox and click
the submit button, the PlaceHolder is emty! Also the user input is lost. My
solution is to generate the html table with each request in the form_load
method. Then, the textbox and the entered text are available. But this is a
very bad solution.

Does anyone know a better way for handling that?

Thanks in advance.

Michael
 
C

chad [email at] gosigma.com

I think that you have two options:

1. Regenerate the table, so that the values are populated (this is by
design of Asp.Net).

2. Maybe you are giving the textboxes unique IDs, so you could get teh
user values from the Page.Request.Form name-value collection, with
something like:

foreach (string key in Page.Request.Form.Keys)
{
string val = Page.Request.Form[key];
}

HTH,

Chad Evans
 
M

Michael Meckelein

chad [email at] gosigma.com said:
I think that you have two options:

1. Regenerate the table, so that the values are populated (this is by
design of Asp.Net).
This is what I currently do.
2. Maybe you are giving the textboxes unique IDs, so you could get teh
user values from the Page.Request.Form name-value collection, with
something like:

foreach (string key in Page.Request.Form.Keys)
{
string val = Page.Request.Form[key];
}
This looks like a good idea. I will try it, thx

Michael
 

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,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top