currently I'm writing code to make variable sized tables with asp:controls in them that look something like this:
TableRow tableHeader = new TableRow();
tableHeader.ID = "tableHeader";
userTable.Rows.Add(tableHeader);
TableCell tableHeaderCell_1 = new TableCell();
tableHeader.Cells.Add(tableHeaderCell_1);
TableCell tableHeaderCell_2 = new TableCell();
Label lblThc2 = new Label();
lblThc2.Text = "<b>Name:</b>";
tableHeaderCell_2.Controls.Add(lblThc2);
tableHeader.Cells.Add(tableHeaderCell_2);
TableCell tableHeaderCell_3 = new TableCell();
Label lblThc3 = new Label();
lblThc3.Text = "<b>User</b>";
tableHeaderCell_3.Controls.Add(lblThc3);
tableHeader.Cells.Add(tableHeaderCell_3);
...
and bodies that look like:
for(int i = 0; i < dynamicTableLength; i++)
{
TableRow tableBodyTemp = new TableRow();
tableBodyTemp.ID = "tableBody" + i;
userTable.Rows.Add(tableBodyTemp);
TableCell tableBodyCell_1 = new TableCell();
Label lblThc2 = new Label();
lblThc2.Text = "<b>"+ i +"</b>";
tableBodyCell_1.Controls.Add(lblThc2);
tableHeader.Cells.Add(tableHeaderCell_1);
TableCell tableBodyCell_2 = new TableCell();
TextBox text = new TextBox();
text.ID = "name" + i;
text.GroupName = "myGroup";
tableHeader.Cells.Add(tableHeaderCell_2);
...
}
There has to be a better way to create tables/forms when you don't know how many rows you need.... or in general!
Can someone help?