Export GridView to Word
-
Hello, I am using the basic export to Word code for my GridView below. I am trying to figure out how to remove the hidden input field that gets added to the output from the StringWriter. Response.Clear(); Response.AddHeader("content-disposition", "attachment;filename=TheFile" + FileDateTime("doc")); Response.Buffer = true; Response.ContentType = "application/vnd.word"; Response.Charset = ""; this.EnableViewState = false; System.IO.StringWriter oStringWriter = new System.IO.StringWriter(); System.Web.UI.HtmlTextWriter oHtmlTextWriter = new System.Web.UI.HtmlTextWriter(oStringWriter); HtmlForm fakeForm = new HtmlForm(); this.Controls.Add(fakeForm); fakeForm.Controls.Add(gvMine); fakeForm.RenderControl(oHtmlTextWriter); Response.Write(oStringWriter.ToString()); Thanks for the help. RB
-
Hello, I am using the basic export to Word code for my GridView below. I am trying to figure out how to remove the hidden input field that gets added to the output from the StringWriter. Response.Clear(); Response.AddHeader("content-disposition", "attachment;filename=TheFile" + FileDateTime("doc")); Response.Buffer = true; Response.ContentType = "application/vnd.word"; Response.Charset = ""; this.EnableViewState = false; System.IO.StringWriter oStringWriter = new System.IO.StringWriter(); System.Web.UI.HtmlTextWriter oHtmlTextWriter = new System.Web.UI.HtmlTextWriter(oStringWriter); HtmlForm fakeForm = new HtmlForm(); this.Controls.Add(fakeForm); fakeForm.Controls.Add(gvMine); fakeForm.RenderControl(oHtmlTextWriter); Response.Write(oStringWriter.ToString()); Thanks for the help. RB