定义Label Label1,如果Label1是变量,怎么定义?

解决方案 »

  1.   

    楼上的  findcontrol,然后赋值 什么意义 ?
      请给出example!!!
      

  2.   

    Control myControl1 = FindControl("Label1");
    if (myControl1 != null)
    {   
        ((System.Web.UI.WebControls.Label)(myControl1)).Text = "asdfsdfsdf";
    }
      

  3.   

    我这个label1是字符串变量,也许存的是"label1"也许是"label2",总之我定义很多控件,每次给label1赋予不同的值。
      

  4.   

    Control myControl;for (int i = 0; i < 5; i++)
    {
        myControl1 = FindControl("Label" + (i + 1).ToString());
        if (myControl != null)
        {   
            ((System.Web.UI.WebControls.Button)(myControl)).Text = "XXX";
        }
    }
      

  5.   

    Control myControl;for (int i = 0; i < 5; i++)
    {
        myControl = FindControl("Label" + (i + 1).ToString());
        if (myControl != null)
        {   
            ((System.Web.UI.WebControls.Button)(myControl)).Text = "XXX";
        }
    }
      

  6.   

    那就在PAGELOAD中动态加载了。