Asked By blake miller
21-Sep-04 04:42 AM

I have tried recreating the controls that I had dynamically created prior to postback, and I can access the controls, but their values are all null. I've seen this answer (that you have to "recreate" the controls after postback), but I'm doing this, and the controls still show as not having anything in them.
What I have:
Upon page load, I create several textbox objects and add them to a System.Web.UI.WebControls.Table object. Here's some sample code:
Protected WithEvents dynInsertTbl As System.Web.UI.WebControls.Table
Dim bCell As System.Web.UI.WebControls.TableCell
Dim tmp As New System.Web.UI.WebControls.TextBox
Dim boxRow As New System.Web.UI.WebControls.TableRow
tmp.ID = colHeaders(i)
tmp.Width = System.Web.UI.WebControls.Unit.Pixel(45)
bCell = New System.Web.UI.WebControls.TableCell
bCell.Controls.Add(tmp)
boxRow.Cells.Add(bCell)
dynInsertTbl.Rows.Add(boxRow)
Upon post back, I call a function that does exactly the above, and then print out the textboxes:
Response.Write(CType(dynInsertTbl.Rows(1).Cells(i).Controls(0), TextBox).Text().Trim() + "<br />")
Note: there are several textboxes, hence why I use "cells(i)" above.
When I access the textbox upon postback, it doesn't show what I typed into the textbox prior to postback?
I don't really understand why recreating the textboxes allows you to access the dynamically generated textboxes. Doesn't recreating the textbox also set it's value to null?