|
I use a dynamic way to automatically generate a lot of text boxes on the page
for(int i = 1;i<100;i++)
{
TextBox t = new TextBox()
t.ID = "a"+i.ToString();
this.Page.Controls.Add(t);
}
Use when getting
string b;
for (in i=1;i<=100;i++)
{
TextBox ck= (TextBox)this.FindControl("a"+i.ToString());
b=ck.text
}
There is an error when acquiring, and the value can be obtained when i=1 during the loop, and an error will occur when the loop continues
Unable to cast object of type'System.Web.UI.WebControls.DropDownList' to type'System.Web.UI.WebControls.TextBox'. |
|