반응형
ArrayList arrList = new ArrayList();
getFindControls(this.Page.Controls, ref arrList);
for (int i = 0; i < arrList.Count; i++)
{
if (arrList[i] is DropDownList)
((DropDownList)arrList[i]).Items.Clear();
}
private void getFindControls(ControlCollection webControl, ref ArrayList arrList)
{
for (int i = 0; i < webControl.Count; i++)
{
arrList.Add(webControl[i]);
if (webControl[i].Controls.Count > 0)
getFindControls(webControl[i].Controls, ref arrList);
}
}
getFindControls(this.Page.Controls, ref arrList);
for (int i = 0; i < arrList.Count; i++)
{
if (arrList[i] is DropDownList)
((DropDownList)arrList[i]).Items.Clear();
}
private void getFindControls(ControlCollection webControl, ref ArrayList arrList)
{
for (int i = 0; i < webControl.Count; i++)
{
arrList.Add(webControl[i]);
if (webControl[i].Controls.Count > 0)
getFindControls(webControl[i].Controls, ref arrList);
}
}
반응형