본문 바로가기
Web Program/Asp.net Lecture

모든 컨트롤 찾기

by 현이빈이 2009. 4. 2.
반응형
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);
   }
  }
반응형