locked
creating asp.net controls dynamically RRS feed

  • Question

  • Hi friends

    am new to asp.net ., i want to create asp.net controls dynamically from codebehind file.

    i tried the following:

    Gridview gv=new Gridview();

    gv.Id="mygv";

    .......

    ......

    this.Controls.add(gv);

    am getting error as runat=server related issue.

    how can i set runat=server attribute from codebehind.

    any help appriciated.

    Regards

    Friend511

    • Moved by Jie Bao Wednesday, April 25, 2012 6:07 AM (From:Windows Presentation Foundation (WPF))
    Sunday, April 22, 2012 3:19 PM

All replies

  • You need to add any new control to an existing container as explained in msdn

    http://msdn.microsoft.com/en-us/library/kyt0fzt1.aspx

    This is a wpf forum rather than asp.net and you probably want to find somewhere more appropriate for any further questions.

    Sunday, April 22, 2012 4:19 PM
  • Hi Friend511,

    For ASP.NET questions, we have a dedicated ASP.NET forum. You can access it from this link: http://forums.asp.net/24.aspx/1?Web+Forms+Data+Controls

    Have a nice day,


    Kee Poppy [MSFT]
    MSDN Community Support | Feedback to us

    Monday, April 23, 2012 7:58 AM