title: asp.net table adding rows dynamically don't remain after postback
body: <p>I have a button click event that adds text to a table. However, when I submit the form the values entered into the table don't appear in the postback...  is this possible to do?</p>
  
  <p>Here is my code: </p>
  
  <pre><code>    Protected Sub AddRowToInputTables(table As Table, value As String)
      If table IsNot Nothing Then
          Dim id As String = value.Trim()
          Dim prefix As String = ""
          If (table.ID = "cust_num") Then ' todo - abstract this out and use a parameter for the prefix instead
              prefix = "CN"
          Else
              prefix = "RN"
          End If
          If id &lt;&gt; String.Empty Then
              Dim tr = New TableRow()
              Dim td = New TableCell()
              Dim td2 = New TableCell()
              Dim btnDelete = New ImageButton()
              btnDelete.ID = "btn" &amp; prefix &amp; "_" &amp; id &amp; "_del"
              btnDelete.ImageUrl = "http://res.xxxxxxxx.net/images/delete.png" ' todo - put this in the web.config or settings file
              tr.ID = id
              td.Text = id
              td2.Controls.Add(btnDelete)
              tr.Cells.Add(td)
              tr.Cells.Add(td2)
              Dim rows = New List(Of TableRow)()
              For Each row In table.Rows
                  rows.Add(row)
              Next
              rows.Add(tr)
              table.Rows.Clear()
              table.Rows.AddRange(rows.ToArray())
              cust_num_txt.Value = String.Empty
              res_num_txt.Value = String.Empty
          End If
      End If
  End Sub
  </code></pre>