G
G-Fit
Hello group,
I am trying to do something simple (or so do I think). A web page, with a
Button, each click on it adding a row in a Table below. The result I get is
that the Table always has only one row (the one I'm trying to add), instead
of getting one *more* row after each click. I thought ViewState would keep
my Table as it was and really add the row ?
Here is my Table in the .aspx :
<asp:Table id="tbl" Runat="server" Visible="False">
<asp:TableRow>
<asp:TableHeaderCell Text="Col1" />
<asp:TableHeaderCell Text="Col2" />
<asp:TableHeaderCell Text="Col3" />
</asp:TableRow>
</asp:Table>
and here is the code behind for the button :
TableRow row = new TableRow();
TableCell cell = new TableCell();
cell.Text = "<some computed text>";
row.Cells.Add(cell);
cell = new TableCell();
cell.Text = "<some computed text>";
row.Cells.Add(cell);
cell = new TableCell();
cell.Text = "<some computed text>";
row.Cells.Add(cell);
tbl.Rows.Add(row);
tbl.Visible = true;
I am trying to do something simple (or so do I think). A web page, with a
Button, each click on it adding a row in a Table below. The result I get is
that the Table always has only one row (the one I'm trying to add), instead
of getting one *more* row after each click. I thought ViewState would keep
my Table as it was and really add the row ?
Here is my Table in the .aspx :
<asp:Table id="tbl" Runat="server" Visible="False">
<asp:TableRow>
<asp:TableHeaderCell Text="Col1" />
<asp:TableHeaderCell Text="Col2" />
<asp:TableHeaderCell Text="Col3" />
</asp:TableRow>
</asp:Table>
and here is the code behind for the button :
TableRow row = new TableRow();
TableCell cell = new TableCell();
cell.Text = "<some computed text>";
row.Cells.Add(cell);
cell = new TableCell();
cell.Text = "<some computed text>";
row.Cells.Add(cell);
cell = new TableCell();
cell.Text = "<some computed text>";
row.Cells.Add(cell);
tbl.Rows.Add(row);
tbl.Visible = true;