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!

Table Retaining Values

Status
Not open for further replies.

AtomicChip

Programmer
May 15, 2001
622
CA
I have a table in a web form that I am dynamically creating rows for. Problem is, when I add a new row, the other row disappears. Here is the code:

<%@ Page Language=&quot;c#&quot; EnableViewState=&quot;true&quot; %>
<%@ Import Namespace=&quot;System.Web.UI.WebControls&quot; %>

<script runat=&quot;server&quot;>

void btnTest_Click ( object sender, EventArgs e )
{

TableCell td = new TableCell();
TableRow tr = new TableRow();
Label lbl = new Label();

lbl.Text = &quot;Hello&quot;;
td.Controls.Add ( lbl );

tr.Cells.Add ( td );
tblTest.Rows.Add ( tr );

}

</script>

<body>

<form runat=&quot;server&quot;>

<asp:Table id=tblTest runat=&quot;server&quot;/>
<asp:Button id=btnTest onClick=btnTest_Click runat=&quot;server&quot;/>

</form>

Should this work, or am I missing something obvious? -----------------------------------------------
&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