动态生成10行6列的表;下面有错,大概是cell和tb不能重复使用,请问应该如何修改,是否可清空后继续使用,不再重新定义,谢谢! ...
TextBox tb = new TextBox();
TableCell cell = new TableCell();
for (int i = 1; i <= 10; i++)
{
TableRow row_c = new TableRow();
for (int j = 1; j <= 6; j++)
{
tb.ID = "c_" + j;
cell.Controls.Add(tb);
row_c.Cells.Add(cell);
}
Table_company.Rows.Add(row_c);
}
...
TextBox tb = new TextBox();
TableCell cell = new TableCell();
for (int i = 1; i <= 10; i++)
{
TableRow row_c = new TableRow();
for (int j = 1; j <= 6; j++)
{
tb.ID = "c_" + j;
cell.Controls.Add(tb);
row_c.Cells.Add(cell);
}
Table_company.Rows.Add(row_c);
}
...
for (int i = 1; i <= 10; i++)
{
TableRow row_c = new TableRow();
for (int j = 1; j <= 6; j++)
{
TextBox tb = new TextBox();
TableCell cell = new TableCell();
tb.ID = "c_" + j;
cell.Controls.Add(tb);
row_c.Cells.Add(cell);
}
Table_company.Rows.Add(row_c);
}