Here’s what I had so far, code-wise:
Protected Sub btnAddRow7_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnAddRow7.Click
Dim tableRow As New System.Web.UI.WebControls.TableRow
Dim tableCell As New System.Web.UI.WebControls.TableCell
Dim textBox As New System.Web.UI.WebControls.TextBox
tableCell.Controls.Add(textBox)
tableRow.Cells.Add(tableCell)
tbl7.Rows.Add(tableRow)
End Sub
…but it only adds one row dynamically. After the first addition, more clicks to the button will not add more rows. Any idea why? Better way to do this?
You could rebuild your Table in Page.Load. For example:
This is because the Button Event comes after the Viewstate is registered.
http://msdn.microsoft.com/en-us/library/ms178472.aspx