Gridview RenderControl

Discussion in 'ASP .Net Datagrid Control' started by Philip, Aug 4, 2006.

  1. Philip

    Philip Guest

    I need to capture the HTML output from a Gridview control....so I am
    executing the following code...

    StringBuilder sb = new StringBuilder();
    StringWriter sw = new StringWriter(sb);
    HtmlTextWriter htw = new HtmlTextWriter(sw);
    MyGridview.RenderControl(htw);


    This technique works fine with many controls, however with the Gridview I
    get the following HttpException...

    "...MyGridview of type "Gridview" must be placed inside a form tag with
    runat=server.

    Of course....it is placed inside of a form tag.... I am simply trying to
    capture the rendered HTML output beforehand.

    Can you suggest an alternative, why this works with other controls ?....

    Thanks


    --
    Philip
     
    Philip, Aug 4, 2006
    #1
    1. Advertising

  2. Philip

    Riki Guest

    Philip wrote:
    > I need to capture the HTML output from a Gridview control....so I am
    > executing the following code...
    >
    > StringBuilder sb = new StringBuilder();
    > StringWriter sw = new StringWriter(sb);
    > HtmlTextWriter htw = new HtmlTextWriter(sw);
    > MyGridview.RenderControl(htw);
    >
    >
    > This technique works fine with many controls, however with the
    > Gridview I get the following HttpException...
    >
    > "...MyGridview of type "Gridview" must be placed inside a form tag
    > with runat=server.
    >
    > Of course....it is placed inside of a form tag.... I am simply trying
    > to capture the rendered HTML output beforehand.
    >
    > Can you suggest an alternative, why this works with other controls
    > ?....
    >
    > Thanks


    See http://aspalliance.com/771

    --

    Riki
     
    Riki, Aug 8, 2006
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. George Ter-Saakov

    Render vs RenderControl

    George Ter-Saakov, Nov 10, 2003, in forum: ASP .Net
    Replies:
    3
    Views:
    20,069
    sobin
    Oct 25, 2006
  2. Kathy Burke
    Replies:
    2
    Views:
    3,757
    Kathy Burke
    Nov 11, 2003
  3. Steve Chatham

    Datagrid to Excel - error - rendercontrol

    Steve Chatham, Feb 23, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    477
    Steve Chatham
    Feb 23, 2004
  4. Ken Boone via .NET 247

    form RenderControl doesn't work in win app

    Ken Boone via .NET 247, Sep 22, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    807
    Norman Yuan
    Sep 22, 2004
  5. charles

    RenderControl and Web User Controls

    charles, Oct 9, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    449
    charles
    Oct 9, 2004
Loading...

Share This Page