title: Dynamically adding columns to ASP.NET table - postback
body: <p>I've have on my aspx page an asp.net table control, containing
  asp.net TableRow objects;</p>
  
  <p>My purpose is to dynamically add columns to this table by clicking some image button.
  The table consists of several TableRow objects, each containing by default an ASP.NET TableCell with some label. I am trying to add the columns by clicking the image button, supposedly adding a new cell to the cell collection of the row. For example if I want to add a column containing a dropdown list for a specific row, I do:</p>
  
  <pre><code>DropDownList ddl = new DropDownList();
              TableCell tableCell= new TableCell();
              tableCell.Controls.Add(ddl);
              tableRow.Cells.Add(tableCell);
  </code></pre>
  
  <p>The problem is that I can never go beyond one added column, because whenever I click the asp.net "AddColumn" button I've created, before I get to its handler somewhere in the life
  cycle the TableRow object dies, along with its collection of cells. 
  I've thought about saving copies of the row objects in session somehow, but I can't think
  of a correct point in time to do the saving.</p>
  
  <p>And anyhow - isn't the asp.net supposed to keep everything in viewstate? Please help and provide solutions. I'm totally confused. </p>
  
  <p>The ASPX btw looks something like this:</p>
  
  <pre><code>&lt;asp:TableRow runat="server" ID="RequestorEmailRow"&gt;
                          &lt;asp:TableCell runat="server" Text="..."&gt;
                          &lt;/asp:TableCell&gt;
                      &lt;/asp:TableRow&gt;
  </code></pre>