日期:2014-05-18 浏览次数:20440 次
//添加代码 Panel1.Controls.Clear(); for (int i = 0; i < Convert.ToInt32(DlPerson.SelectedValue); i++) { Panel1.Controls.Add(new TextBox() { Text="姓名"+i.ToString(), ID="lbl"+i.ToString() }); } //遍历代码 for (int i = 0; i < Panel1.Controls.Count; i++) { if (Panel1.Controls[i] is TextBox) { TextBox tb = Panel1.Controls[i] as TextBox; guestList.Add(new Guest() { Name = tb.Text, RoomNumber = i.ToString() }); } }