c# 时我动态生成了一个textbox?可.text属性的值我却不知该如何引用?

来源:百度知道 编辑:UC知道 时间:2024/05/22 07:19:27
怎么办?

假设在本页面添加一个TextBox名称为txt
TextBox txt=new TextBox();
this.Controls.Add(txt);
这就添加了一个文本框了。
要使用.text属性是一样的
Response.Write(txt.Text);

private void AddTextBoxs()
{
TableRow tr = new TableRow();
TableCell TCPartNo = new TableCell();
TableCell TCPartName = new TableCell();
TextBox TBPartNo = new TextBox();
TextBox TBPartName = new TextBox();
TBPartNo.ID = "TBPartNo" + TableNewRow.Rows.Count;
TBPartName.ID = "TBPartName" + TableNewRow.Rows.Count;
TBPartNo.Width = 119;
TBPartName.Width = 170;
TCPartNo.Controls.Add(TBPartNo);
TCPartName.Controls.Add(TBPartName);
tr.Cells.Add(TCPartNo);
tr.Cells.Add(TCPartName);
TableNewRow.Rows.Add(tr);
}
本人做过的东东
如果不行请发短消息给我