I added TableRows through the code for the table. Lines are displayed on the page, but on PostBack, the lines are no longer part of the collection. What is the trick to keep these lines saved so that I can use them in PostBack?
.ascx
<asp:Table id="OrderItemsTable" runat="server">
.ascx.cs
TableRow itemRow = new TableRow(); // Ticket Quantity TableCell cell1 = new TableCell(); cell1.Attributes.Add("align", "center"); TextBox ticket1QuantityTextBox = new TextBox(); ticket1QuantityTextBox.Width = Unit.Pixel(30); ticket1QuantityTextBox.MaxLength = 3; ticket1QuantityTextBox.Attributes.Add("class", "OrderItemTicketQuantityTB"); ticket1QuantityTextBox.Text = item.Quantity.ToString(); cell1.Controls.Add(ticket1QuantityTextBox); itemRow.Cells.Add(cell1); ... OrderItemsTable.Rows.Add(itemRow);
source share