Gridview RenderControl

P

Philip

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
 
R

Riki

Philip said:
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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,037
Messages
2,570,371
Members
47,013
Latest member
JewellChes

Latest Threads

Top