// 假如按下“Add”按钮,那么count加一 string target = this.Request["btnAdd"]; if (target == "Add") { _count++; } // 动态创建控件 for (int i = 0; i < _count; i++) { // 这里以TextBox为例,实际上需要创建的是WebPartZone TextBox newTextbox = new TextBox(); newTextbox.ID = "TXT" + i.ToString(); this.PlaceHolder1.Controls.Add(newTextbox); } } protected void Page_Load(object sender, EventArgs e) { hfCount.Value = _count.ToString(); } protected void btnAdd_Click(object sender, EventArgs e) { // 不能在此添加WebPartZone控件,只能在OnInit或之前,否则报异常 } } 希望大家能提出更好的解决方案,我拭目以待,呵呵@_@ http://www.cnblogs.com/leafyoung/archive/2007/04/04/699465.html |