Adding rows to a Tablecontrol does not save in viewstate

Discussion in 'ASP .Net Web Controls' started by Allan Ebdrup, Oct 3, 2005.

  1. Allan Ebdrup

    Allan Ebdrup Guest

    I'm Using ASP.Net 2.0 and VS2005 RC.
    I've added a TableControl and a Wizard Control to my ASP.Net Page.
    When i Click Finish on the wizard I do the following code:

    TableRow tr = new TableRow();
    TableCell tc = new TableCell();
    tc.Text = "TEST";
    tr.Cells.Add(tc);
    Table1.Rows.Add(tr);

    And a TEST row is added to the table, but when I jump back to step 1 of the
    wizard or do anything else that reloads the page, the TEST row is deleted
    again. I have enabled viewstate on the table control. Why is my test row
    disappearing? And how can I make the TEST row stay, even after page reloads?

    Kind Regards,
    Allan Ebdrup
     
    Allan Ebdrup, Oct 3, 2005
    #1
    1. Advertising

  2. Allan Ebdrup

    Brock Allen Guest

    Any controls that are dynamically added to the page must be added again upon
    every postback.

    -Brock
    DevelopMentor
    http://staff.develop.com/ballen

    > I'm Using ASP.Net 2.0 and VS2005 RC.
    > I've added a TableControl and a Wizard Control to my ASP.Net Page.
    > When i Click Finish on the wizard I do the following code:
    > TableRow tr = new TableRow();
    > TableCell tc = new TableCell();
    > tc.Text = "TEST";
    > tr.Cells.Add(tc);
    > Table1.Rows.Add(tr);
    > And a TEST row is added to the table, but when I jump back to step 1
    > of the wizard or do anything else that reloads the page, the TEST row
    > is deleted again. I have enabled viewstate on the table control. Why
    > is my test row disappearing? And how can I make the TEST row stay,
    > even after page reloads?
    >
    > Kind Regards,
    > Allan Ebdrup
     
    Brock Allen, Oct 4, 2005
    #2
    1. Advertising

  3. Allan Ebdrup

    Allan Ebdrup Guest

    "Brock Allen" <> wrote in message
    news:...
    > Any controls that are dynamically added to the page must be added again
    > upon every postback.


    Why does a table control have the option to enable viewstate then? it has no
    viewstate. It the viewstate enabeling inherited to controls inside the
    table?

    Kind Regards,
    Allan Ebdrup
     
    Allan Ebdrup, Oct 5, 2005
    #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. Subba Rao via DotNetMonster.com

    script for moving rows up and down and traverse thru rows of HTML table

    Subba Rao via DotNetMonster.com, Mar 19, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    8,351
    Subba Rao via DotNetMonster.com
    Mar 19, 2005
  2. helpful sql
    Replies:
    0
    Views:
    853
    helpful sql
    May 19, 2005
  3. Arjen Hoekstra
    Replies:
    0
    Views:
    588
    Arjen Hoekstra
    Aug 2, 2005
  4. Jonas
    Replies:
    0
    Views:
    178
    Jonas
    Sep 23, 2003
  5. DataGrid rows not recreated from ViewState

    , Sep 13, 2006, in forum: ASP .Net Web Controls
    Replies:
    1
    Views:
    152
Loading...

Share This Page