panel中动态生成的textbox,然后那把填的内容插入到数据库,好像有问题

来源:百度知道 编辑:UC知道 时间:2024/06/02 15:54:18
好像点提交时,panel中的textbox没了,或输入的内容没了

protected void Button1_Click(object sender, EventArgs e)
{
TextBox txt = new TextBox();
txt.ID = "txt1";
this.Panel1.Controls.Add(txt);
}
protected void Button2_Click(object sender, EventArgs e)
{
Response.Write(Request.Form["txt1"]);
}
为每个TextBox设置一个有规律的ID,然后用Reuqest.Form去取得就可以了。
至于TextBox刷新后消失,用静态变量在Page_Init里重新加一遍就可以了.