Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

asp:Table EnableViewState

Status
Not open for further replies.

AtomicChip

Programmer
May 15, 2001
622
CA
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=&quot;server&quot;/>
<asp:Button id=btn runat=&quot;server&quot;/>

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 ( &quot;test&quot; ) );
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.)? -----------------------------------------------
&quot;The night sky over the planet Krikkit is the least interesting sight in the entire universe.&quot;
-Hitch Hiker's Guide To The Galaxy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top