PlaceHolder ph = new PlaceHolder();
       ph.ID = "fd";
        for (int i = 1; i <= 3; i++)
       {
           Label label = new Label();
           label.ID = "lbl" + i;
           label.Text = "<a href=></a>";
           ph.Controls.Add(label);       }
      
      
       form1.Controls.Add(ph);
运行后label没有显示,这怎么回事啊?

解决方案 »

  1.   

    <asp:PlaceHolder id="PlaceHolder1" 
               runat="server"/>
    页面上放一个这样的!!然后再添加!!
      

  2.   

    Button Button1 = new Button();
        Button1.Text = "Button 1";
        PlaceHolder1.Controls.Add(Button1);
        
        Literal Literal1 = new Literal();
        Literal1.Text = "<br>";
        PlaceHolder1.Controls.Add(Literal1);
        
        Button Button2 = new Button();
        Button2.Text = "Button 2";
        PlaceHolder1.Controls.Add(Button2);
      

  3.   

    PlaceHolder ph = new PlaceHolder();
                
                ph.ID = "fd";
                for (int i = 1; i <= 3; i++)
                {
                    Label label = new Label();
                    label.ID = "lbl" + i;
                    label.Text = " <a href=''>123</a>";
                    ph.Controls.Add(label);            }
                
                this.Controls.Add(ph);这个可以显示的
      

  4.   

    label.Text = " <a href=> </a>"; 你没加内容怎么会显示。。
      

  5.   

    放到 page_load事件中试试http://www.mybuffet.cn