AtomicChip
Programmer
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="c#" EnableViewState="true" %>
<%@ Import Namespace="System.Web.UI.WebControls" %>
<script runat="server">
void btnTest_Click ( object sender, EventArgs e )
{
TableCell td = new TableCell();
TableRow tr = new TableRow();
Label lbl = new Label();
lbl.Text = "Hello";
td.Controls.Add ( lbl );
tr.Cells.Add ( td );
tblTest.Rows.Add ( tr );
}
</script>
<body>
<form runat="server">
<asp:Table id=tblTest runat="server"/>
<asp:Button id=btnTest onClick=btnTest_Click runat="server"/>
</form>
Should this work, or am I missing something obvious? -----------------------------------------------
"The night sky over the planet Krikkit is the least interesting sight in the entire universe."
-Hitch Hiker's Guide To The Galaxy
<%@ Page Language="c#" EnableViewState="true" %>
<%@ Import Namespace="System.Web.UI.WebControls" %>
<script runat="server">
void btnTest_Click ( object sender, EventArgs e )
{
TableCell td = new TableCell();
TableRow tr = new TableRow();
Label lbl = new Label();
lbl.Text = "Hello";
td.Controls.Add ( lbl );
tr.Cells.Add ( td );
tblTest.Rows.Add ( tr );
}
</script>
<body>
<form runat="server">
<asp:Table id=tblTest runat="server"/>
<asp:Button id=btnTest onClick=btnTest_Click runat="server"/>
</form>
Should this work, or am I missing something obvious? -----------------------------------------------
"The night sky over the planet Krikkit is the least interesting sight in the entire universe."
-Hitch Hiker's Guide To The Galaxy