AtomicChip
Programmer
Is it just me, or does the EnableViewState property of the asp:Table control not seem to work? In my webform, I have the following:
<asp:Table id=tbl runat="server"/>
<asp:Button id=btn runat="server"/>
And in my code, I have:
void Page_Load ( object sender, EventArgs e )
{
if (!Page.IsPostBack)
{
for ( int i = 0; i < 5; i++ )
{
TableCell td = new TableCell();
TableRow tr = new TableRow();
td.Controls.Add ( new LiteralControl ( "test" ) );
tr.Cells.Add ( td );
tblTest.Rows.Add ( tr );
td = null;
tr = null;
}
}
}
(Of course, all required namespaces are included)... Problem is, when I click the button and the page is posted back, the table contents disappear. I have tried setting EnableViewState=true in both the HTML and the c# code and neither work. Is there something that I'm missing, or is there no way to get this to work? If there isn't any way to get this to work, is there another control that can be used the exact same way as the table control (cells, rows, etc.)? -----------------------------------------------
"The night sky over the planet Krikkit is the least interesting sight in the entire universe."
-Hitch Hiker's Guide To The Galaxy
<asp:Table id=tbl runat="server"/>
<asp:Button id=btn runat="server"/>
And in my code, I have:
void Page_Load ( object sender, EventArgs e )
{
if (!Page.IsPostBack)
{
for ( int i = 0; i < 5; i++ )
{
TableCell td = new TableCell();
TableRow tr = new TableRow();
td.Controls.Add ( new LiteralControl ( "test" ) );
tr.Cells.Add ( td );
tblTest.Rows.Add ( tr );
td = null;
tr = null;
}
}
}
(Of course, all required namespaces are included)... Problem is, when I click the button and the page is posted back, the table contents disappear. I have tried setting EnableViewState=true in both the HTML and the c# code and neither work. Is there something that I'm missing, or is there no way to get this to work? If there isn't any way to get this to work, is there another control that can be used the exact same way as the table control (cells, rows, etc.)? -----------------------------------------------
"The night sky over the planet Krikkit is the least interesting sight in the entire universe."
-Hitch Hiker's Guide To The Galaxy