foreach (Control c in this.Controls)
        {
            if (c is Content)
            {
                foreach (Control cbl in c.Controls)
                {
                    if (cbl is CheckBox)
                    {
                        CheckBox cb = (CheckBox)cbl;
                        int userid =System.Convert.ToInt32(Request["userid"]);
                        Int16 cb_id = System.Convert.ToInt16(cb.ID);
                        string cb_checked = System.Convert.ToString(cb.Checked);
                        dr.update_user_right(userid,cb_id,cb_checked);                    }
                }            }
        }
     this.Controls的count的值怎么只有1啊,哪位大哥可以帮帮我

解决方案 »

  1.   

    to this.Controls的count的值怎么只有1啊,哪位大哥可以帮帮我你这段代码写在哪里,还有你的控件是否都加载到this.Controls中。
      

  2.   

    第一,要么你用递归来搞
    第二,改你的第一句为
    foreach (Control c in this.Controls[1].Controls)看这样子你是在ASP.NET页面里面找Control,你直接foreach (Control c in this.Controls)当然只有1,因为第1个(索引是0)是Form,而你的控件都在Form里面
      

  3.   

    http://community.csdn.net/Expert/topic/4769/4769634.xml?temp=.2866938
    参考此贴......
      

  4.   

    this.Controls只含一级子控件啊。如果写成通用的,应该要用递归来做