dynamic html table with textboxes

Discussion in 'ASP .Net' started by Michael Meckelein, Apr 13, 2004.

  1. 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
     
    Michael Meckelein, Apr 13, 2004
    #1
    1. Advertising

  2. 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


    Michael Meckelein wrote:

    > 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
    >
     
    chad [email at] gosigma.com, Apr 13, 2004
    #2
    1. Advertising

  3. "chad [email at] gosigma.com" <"chad [email at] gosigma.com"> wrote in
    message
    > 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
     
    Michael Meckelein, Apr 14, 2004
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Brian Pittman

    Dynamic TextBoxes

    Brian Pittman, Nov 13, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    359
    Anatoly
    Nov 13, 2003
  2. =?Utf-8?B?Qm9vbmFhcA==?=

    dynamic webform - repeat textboxes

    =?Utf-8?B?Qm9vbmFhcA==?=, Mar 21, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    357
    Karl Seguin
    Mar 21, 2005
  3. =?Utf-8?B?dGhlIGZyaWVuZGx5IGRpc3BsYXkgbmFtZQ==?=

    Dynamic Textboxes

    =?Utf-8?B?dGhlIGZyaWVuZGx5IGRpc3BsYXkgbmFtZQ==?=, Sep 9, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    2,511
    =?Utf-8?B?dGhlIGZyaWVuZGx5IGRpc3BsYXkgbmFtZQ==?=
    Sep 9, 2005
  4. theresa
    Replies:
    1
    Views:
    558
    =?Utf-8?B?bXVzb3NkZXY=?=
    Jun 26, 2006
  5. Elmo Watson
    Replies:
    0
    Views:
    419
    Elmo Watson
    May 8, 2007
Loading...

Share This Page