if (this.TextBox1.Text.Trim() != "")
{
int len = int.Parse(this.TextBox1.Text.Trim());
for (int i = 0; i < len; i++)
{
TableCell tc = new TableCell();
TableCell tc2 = new TableCell();
TextBox txt = new TextBox();
txt.ID = "txt" + i.ToString();
LiteralControl lc = new LiteralControl("<input id='Button2' type='button' value='button' οnclick=javascript:fun('"+txt.ID+"') />");
tc.Controls.Add(txt);
tc2.Controls.Add(lc);
TableRow tr = new TableRow();
tr.Cells.Add(tc);
tr.Cells.Add(tc2);
this.Table1.Rows.Add(tr);
}
}
转载于:https://www.cnblogs.com/MySpace/archive/2009/11/10/1599769.html