I am creating a webpart to be used inside Sharepoint using VS 2005. I am displaying data from an xml file into an SPGridView. I wanted to export the grid data into a word document via a button click. In my button click event, I have this code attached.
When I run this, I'm getting an error:
c__grid' of type 'SPGridView' must be placed inside a form tag with runat=server
For testing, I created a project in VS.Net and put the entire code. I got the error and search the net and the solution is I need to put:
public override void VerifyRenderingInServerFor
to tell ASP.Net that there is a control that needs to be rendered at runtime.
I can't put this in my webpart as I got the error no suitable method found to override. I am getting the error on the part
Can you please help me and If this is not possible, are there alternative ways to output grid data to Word.
Thanks a lot.
void print_Click(object sender, EventArgs e)
Context.Response.Buffer = true;
//Context.Response.ContentEncoding = System.Text.Encoding.UTF7;
Context.Response.ContentType = "application/msword";
System.IO.StringWriter oStringWriter = new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter oHtmlTextWriter = new HtmlTextWriter(oStringWriter);