I want to be able to add a usercontrol on the fly. The code below adds the usercontrol to the Web page. The problem is that each time I add one the previous one is lost. Is there any way I can fix this problem?
Code:
Private Sub AddESOItem()
Dim tCell As TableCell
Dim tRow As TableRow
Dim ucESOitem As ESOItem
Dim i As Int16 = (Me.Session.Item("ESOItemNo"))
ucESOitem = New ESOItem
ucESOitem = CType(LoadControl("ESOItem.ascx"), ESOItem)
tCell = New TableCell
tRow = New TableRow
ucESOitem.ID = "ESOItem" & i
tCell.Controls.Add(ucESOitem)
tRow.Cells.Add(tCell)
Me.tblDetails.Rows.Add(tRow)
Me.Session.Item("ESOItemNo") = Me.Session.Item("ESOItemNo") + 1
End Sub