I have an asp table with 5 rows and a button that, when clicked by the user, adds an additional row to the table. The row contains 5 cells for the user to input information into.

When the text changes in the 3rd cell, its supposed to calculate the sum of the 2nd and 3rd cell BUT as soon as you click out of the 3rd cell, the entire row is deleted. I know this is because the row is created dynamically and erased on the page post back, but does anyone have a simple solution for how to recreate the row and information entered by the user/keep the row from being removed ?

Are these rows being added client side or server side?

@JorgeM, good question... I actually assumed it was on server side because the post is on ASP.NET Forum, but who knows, right?!

Thanks for responding guys. I'm not sure which side they are being added on. I have the form published to ISS

Here's my code

Imports System.Data.SqlClient
Imports System.Security.Principal
Imports System.Data.OleDb
Imports System.DirectoryServices

Public Class Budget_Worksheet
    Inherits System.Web.UI.Page
    Declare Function LogonUserA Lib "advapi32.dll" (ByVal lpszUsername As String, ByVal lpszDomain As String, ByVal lpszPassword As String, ByVal dwLogonType As Integer, ByVal dwLogonProvider As Integer, ByRef phToken As IntPtr) As Integer

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

    End Sub

    'handles the Add Row column being clicked
    Protected Sub BWAddRowButton_Click(sender As Object, e As EventArgs) Handles BWAddRowButton.Click
        Dim numRows As Integer = BWInputTable.Rows.Count

        AddRow_InputTable(numRows) 'add row to the Input Table
        'AddRow_TaskTable(numRows) 'add row to the Task Table
        'AddRow_TotalsTable(numRows) 'add row to the Calculations Table
    End Sub

    'add row to input table
    Public Function AddRow_InputTable(ByVal numRows As Integer)
        'create the row
        Dim inputRow As New TableRow()
        inputRow.ID = "BWInputRow" & (numRows).ToString
        inputRow.Visible = True

        'create the cells for the row and add each to the row
        Dim cellNum As Integer = 0
        For Each cell As TableCell In BWInputTable.Rows(0).Cells
            'create cell
            Dim inputCell As New TableCell
            inputCell.ID = "BWInputRow" & (numRows).ToString & "Cell" & cellNum.ToString 'create cell ID
            inputCell.Width = 125 'set cell width
            inputCell.Visible = True 'set to visible

            'create hours text box
            Dim hoursTextBox As New TextBox
            hoursTextBox.ID = "BWHoursRow" & (numRows).ToString & "Cell" & cellNum.ToString 'create text box ID
            AddHandler hoursTextBox.TextChanged, AddressOf calculateColumnAndRowTotals 'set the "on text changed" property value
            hoursTextBox.AutoPostBack = True
            hoursTextBox.Width = 125
            hoursTextBox.Text = hoursTextBox.ID

            'add the text box to the cell

            'add the cell to the row

            cellNum = cellNum + 1

        'add the row to the table
    End Function

The ViewStateMode is set to Inherit, EnableViewState is set to Yes

Oh, sorry, I forgot this thread... did you fix the problem?

And I was wrong... ViewState only store the values for the dynamic controls, but it does not regenerate those controls.

You'll have to store each added row somewhere(DB, Session, file and etc) and then create those rows at Page_Load. Something like:

if ( IsPostBack ) {