假设你是WINForm,并且form1上有3个Labelfor (int i = 1; i <= 3; i++)
            {
                Control[] controls = this.Controls.Find("label" + i, true);
                foreach (Control c in controls)
                {
                    if (c.GetType() == typeof(Label))
                    {
                        ((Label)c).Text = "某一值";
                    }
                }
            }

解决方案 »

  1.   

    System.Web.UI.ControlCollection”不包含“Find”的定义
    照你的方法出现上述错误?
      

  2.   

    哈哈.你没说环境,我也已经说了:假设你是WINForm,并且form1上有3个Label 不好意思.WEB我就不会了.
      

  3.   

    for(int i=0;i<N;i++)
    {
      Label lbl = (Label)this.FindControl("label"+i);
      lbl.Text = "想赋的值";
    }
      

  4.   

    看了一下.原来WEB也很简单: 
    for (int i = 1; i <= 3; i++) 
            { 
                ((Label)Page.FindControl("Label" + i)).Text = "xxx"; 
            }
      

  5.   

    用foreach循环挨个遍历页面或者窗口上面的控件,再赋值就行了
            foreach (Control  c in this.Page.Form .Controls   )
            {
                if (c is Label )
                {
                    ((Label)c).Text = "hello";
                }
            }这个是挨个遍历赋的值相同
      

  6.   


    呵呵.这个遍历会把所有LABEL都赋值,如果有其它名称而又不想改它的值的时候,这样就会小有问题.