Hey guys, I'm having a problem and need some help. I have an <asp:table ...>
in my web page, and this table has 2 rows, the first being a header row, and
the second row containing an <asp:button> to add rows to the table. Well,
when I add the first row it shows up, but if I try to add any more rows, the
one I added + the rest of them all disappear. I tried saving the table to a
Session variable, but that didn't work. I'm not really sure what is going
on, but any help would be appreciated.
CODE:
ASP:
<asp:table runat="server" id="InvolvementTable">
<asp:tablerow id="row1">
<asp:tableheadercell>Name</asp:tableheadercell>
<asp:tableheadercell>Details</asp:tableheadercell>
</asp:tablerow>
<asp:tablerow>
<asp:tablecell columnspan="2" horizontalalign="Center">
<asp:button runat="server" id="addRowButton" text="Add
Row"></asp:button>
</asp:tablecell>
</asp:tablerow>
</asp:table>
C#:
System.Web.UI.WebControls.TableRow r = new TableRow();
System.Web.UI.WebControls.TableCell c = new TableCell();
c.Text = "<input type=\"text\" size=\"30\" id=\"personInvolved" + count +
"\" />";
c.HorizontalAlign = System.Web.UI.WebControls.HorizontalAlign.Center;
r.Cells.Add(c);
c = new TableCell();
c.Text = "<input type=\"text\" size=\"30\" id=\"personInvolvedDesc" + count
+ "\" />";
c.HorizontalAlign = System.Web.UI.WebControls.HorizontalAlign.Center;
r.Cells.Add(c);
InvolvementTable.Rows.AddAt(InvolvementTable.Rows. Count-1, r);
Session["RowCount"] = ++count;
Session["InvolveTable"] = InvolvementTable;
--
If you can't beat them, arrange to have them beaten...