动态增加控件问题
页面上有一个按钮,按一次就动态增加一个textbox控件,如何实现?
使用如下方法:
protected void Button1_Click(object sender, EventArgs e)
{
((Label)TableHead.FindControl( "Label10 ")).Text = TableHead.Controls.Count.ToString();
rowCount = TableHead.Controls.Count;
string tr,tc1,tc2,tc3,tc4,tc5;
tr = "tr " + rowCount.ToString();
tc1 = "tc " + rowCount.ToString() + "1 ";
tc2 = "tc " + rowCount.ToString() + "2 ";
tc3 = "tc " + rowCount.ToString() + "3 ";
tc4 = "tc " + rowCount.ToString() + "4 ";
tc5 = "tc " + rowCount.ToString() + "5 ";
TableRow tr2 = new TableRow();
tr2.ID = tr;
TableCell tc11 = new TableCell();
tc11.ID = tc1;
TableCell tc21 = new TableCell();
tc21.ID = tc2;
TableCell tc31 = new TableCell();
tc31.ID = tc3;
TableCell tc41 = new TableCell();
tc41.ID = tc4;
TableCell tc51 = new TableCell();
tc51.ID = tc5;
TableHead.Controls.Add(tr2);
tr2.Controls.Add(tc11);
tr2.Controls.Add(tc21);
tr2.Controls.Add(tc31);
tr2.Controls.Add(tc41);
tr2.Controls.Add(tc51);
}
只能在首次按的时候添加了table的一行,再次按由于页面刷新,上次动态添加的无效了,所以无法实现连续的添加控件.如何解决这个问题?用别的方法也可以.
比如有一组文件要上传,我希望是开始显示3个上传栏,用户可以通过点按钮增加更多的上传栏.(一个实际需求的描述),当然我的问题不是这么简单,我简化成这样了,希望大家能明白,希望大家可以帮我解决,我搞了1天都没做出来啊,急啊~
只有90分了,上午散了200分,接分的去我的散分帖子,此90分全部给帮我解决此问题的人,先谢谢大家了.
------解决方案--------------------把这段代