動態控件取值的問題
取不到控件的值,這個可能是加載時的問題,但是用了ispostback,也沒有用。
不清楚是怎麼樣一個問題了。
請過路的大仙們指點一下,感謝人世分!
protected void tbnclick()
{
string jiZhong = TextBox1.Text;
string[] arrJZ = jiZhong.Split(',');
int jiZhongShu = arrJZ.Length;
for (int i = 0; i < jiZhongShu; i++)
{
Table tab = new Table();
tab.ID = "tab" + i.ToString();
for (int b = 0; b < 4; b++)
{
string tr = "";
switch (b)
{
case 0:
tr = "first";
break;
case 1:
tr = "second";
break;
case 2:
tr = "three";
break;
case 3:
tr = "four";
break;
}
TableRow tabr = new TableRow();
for (int r = 0; r < 2; r++)
{
TableCell tabc = new TableCell();
TextBox tb = new TextBox();
tb.ID = tr + "td" + i.ToString();
TableCell tabc1 = new TableCell();
tabc1.Text = tr;
tabc.Controls.Add(tb);
tabr.Cells.Add(tabc);
tabr.Cells.Add(tabc1);
}
tab.Controls.Add(tabr);
}
this.Panel1.Controls.Add(tab);
}