Adding rows to a Tablecontrol does not save in viewstate

A

Allan Ebdrup

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
 
B

Brock Allen

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

Allan Ebdrup

Brock Allen said:
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
 

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,755
Messages
2,569,536
Members
45,014
Latest member
BiancaFix3

Latest Threads

Top