我想循环通过面板中的每个控件,并清除所有内容,如果它是DropDownList。通过循环控件清除DropDownList
以下是我有:
private void ClearOut()
{
foreach (Control list in MainPanel.Controls)
{
if (list.ToString().Equals("System.Web.UI.WebControls.DropDownList"))
{
//Clear it out here
}
}
}
此代码找到每一个DropDownList的,但我无法弄清楚如何清除出来,一旦我到达那里。我不能像使用selectedindex或items.clear()一样使用DropDownList的任何属性。
好水溶液和您还需要()在OfType – 2013-04-09 18:13:07
结束@ J-MAN:当然,谢谢,更新。 – abatishchev 2013-04-09 18:15:34