我的页面里有44个DropDownList
怎么遍历?

解决方案 »

  1.   

    foreach (Control con in this.Page.Controls)
    {
      
    }
      

  2.   

    放這么多DropDownList速度會不會慢?
      

  3.   


    foreach (Control con in this.Page.Controls)
    {
       if(con is DropDownList )
         {
         }
    }
      

  4.   

    假如你的控件在panel里
    foreach (Control con in Panel1.Controls) 

      if(con is DropDownList ) 
        { 
        } 

    不过那你的页面运行速度就太惨了。
      

  5.   

    private void test(Control c)
        {
            foreach (Control childControl in c.Controls)
            {
                if (childControl is DropDownList )
                   {
                   }
                else
                    test(childControl);
            }
        }
    递归实现
      

  6.   

     是页面的话 要这样!
    foreach (Control myc in form1.Controls)
            {
                if (myc is TextBox)
                {
                    TextBox tb = (TextBox)myc;
                    tb.Text = string.Empty; 要做什么在这里做 就可以了。
                }
             }