dynamic html table with textboxes

  • Thread starter Thread starter Michael Meckelein
  • Start date Start date
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
 
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
 
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
 
Back
Top