I have a ASP.NET (WebControl) table that I created on the Designer. It seems like it's losing state, though.
In PageLoad I have the following:
which calls this:
That "AddAVendor" sub is also called by a button click.
It should be adding a row to the table with the first page load and then also each time the button is clicked. It is adding the first row on the first page load - that's the good news. But when the user clicks the (ImageButton) and the page posts back, there no table to be seen on the page anymore. When I check it in the Command Window, it claims it's there with the right number of rows! All parts of the table (rows, cells, table) are visibile = true.
Any ideas why my table disappears - please???
Thanks,
Dot
In PageLoad I have the following:
Code:
If Me.IsPostBack = False Then
tblVendors = CType(Session("tblVendors"), System.Web.UI.WebControls.Table)
Session.Add("vendorCounter", 1)
AddAVendor()
End If
Code:
Private Sub AddAVendor()
Dim newRow As New TableRow
Dim cellVendor As New TableCell
Dim cellFilename As New TableCell
Dim cmbVendor As New DropDownList
Dim tbFilename As New TextBox
cellVendor.Controls.Add(cmbVendor)
cellVendor.ID = "cellVendor" & Session("vendorCounter").ToString - 1
cellFilename.ID = "cellFilename" & Session("vendorCounter").ToString - 1
newRow.ID = "row" & Session("vendorCounter").ToString - 1
newRow.Cells.Add(cellVendor)
newRow.Cells.Add(cellFilename)
cellFilename.Controls.Add(tbFilename)
tblVendors.Rows.Add(newRow)
PopulateVendorsDropDown(cmbVendor)
Session("vendorCounter") += 1
Session("tblVendors") = tblVendors
End Sub
It should be adding a row to the table with the first page load and then also each time the button is clicked. It is adding the first row on the first page load - that's the good news. But when the user clicks the (ImageButton) and the page posts back, there no table to be seen on the page anymore. When I check it in the Command Window, it claims it's there with the right number of rows! All parts of the table (rows, cells, table) are visibile = true.
Any ideas why my table disappears - please???
Thanks,
Dot