不明白为要用两个循环!
一次性清空多个TextBox: foreach (System.Web.UI.Control control in Controls)
{
for (int i = 0; i < control.Controls.Count; i++)
{
if (control.Controls[i] is System.Web.UI.WebControls.TextBox)
{
System.Web.UI.WebControls.TextBox tb = (System.Web.UI.WebControls.TextBox)control.Controls[i];
tb.Text = "";
}
}
}
不理解为什么要两个循环!
foreach (System.Web.UI.Control control in Controls) //历遍容器中每一个控件。
for (int i = 0; i < control.Controls.Count; i++)
//control.Controls.Count 控件的控件的集合?不理解!上面foreach都历遍了,这里干嘛还要历遍?