Excel Conversion Error
-
Thank you all for the quick response!!! my Form tag & Gridview both contains "runat=server" tag in it! ~!!! but no use! grrrrrrr!
-
This peace of code works fine for me. I executed that one and is performing well.
Apurva Kaushal
hmm...but whats wrong from my side: I executed it again but still the same error persists here is the error:: Control 'myGridView' of type 'GridView' must be placed inside a form tag with runat=server. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.Web.HttpException: Control 'myGridView' of type 'GridView' must be placed inside a form tag with runat=server. Source Error: Line 63: System.IO.StringWriter stringWrite = new System.IO.StringWriter(); Line 64: System.Web.UI.HtmlTextWriter htmlWrite = new HtmlTextWriter(stringWrite); Line 65: myGridView.RenderControl(htmlWrite); Line 66: Response.Write(stringWrite.ToString()); Line 67: Response.End();
-
hmm...but whats wrong from my side: I executed it again but still the same error persists here is the error:: Control 'myGridView' of type 'GridView' must be placed inside a form tag with runat=server. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.Web.HttpException: Control 'myGridView' of type 'GridView' must be placed inside a form tag with runat=server. Source Error: Line 63: System.IO.StringWriter stringWrite = new System.IO.StringWriter(); Line 64: System.Web.UI.HtmlTextWriter htmlWrite = new HtmlTextWriter(stringWrite); Line 65: myGridView.RenderControl(htmlWrite); Line 66: Response.Write(stringWrite.ToString()); Line 67: Response.End();
-
Hi All, I need some help. I'm trying to export Gridview into Excel. But i'm getting the following error! "Control 'myGridView' of type 'GridView' must be placed inside a form tag with runat=server." Here is my Code: protected void BtnExport_Click(object sender, EventArgs e) { Response.Clear(); Response.AddHeader("content-disposition", "attachment;filename=FileName.xls"); Response.Charset = ""; // If you want the option to open the Excel file without saving then // comment out the line below // Response.Cache.SetCacheability(HttpCacheability.NoCache); Response.ContentType = "application/ms-excel.xls"; System.IO.StringWriter stringWrite = new System.IO.StringWriter(); System.Web.UI.HtmlTextWriter htmlWrite = new HtmlTextWriter(stringWrite); myGridView.RenderControl(htmlWrite); Response.Write(stringWrite.ToString()); Response.End(); } THIS IS THE GRIDVIEW THAT I'M USING:: But my Gridview is already placed in the form only!!!!:((:confused: could any one please help me on
-
Hi All, I need some help. I'm trying to export Gridview into Excel. But i'm getting the following error! "Control 'myGridView' of type 'GridView' must be placed inside a form tag with runat=server." Here is my Code: protected void BtnExport_Click(object sender, EventArgs e) { Response.Clear(); Response.AddHeader("content-disposition", "attachment;filename=FileName.xls"); Response.Charset = ""; // If you want the option to open the Excel file without saving then // comment out the line below // Response.Cache.SetCacheability(HttpCacheability.NoCache); Response.ContentType = "application/ms-excel.xls"; System.IO.StringWriter stringWrite = new System.IO.StringWriter(); System.Web.UI.HtmlTextWriter htmlWrite = new HtmlTextWriter(stringWrite); myGridView.RenderControl(htmlWrite); Response.Write(stringWrite.ToString()); Response.End(); } THIS IS THE GRIDVIEW THAT I'M USING:: But my Gridview is already placed in the form only!!!!:((:confused: could any one please help me on
DKalepu wrote:
myGridView.RenderControl(htmlWrite);
You cannot render the GridView Control into HTML directly. Use DataGrid. May be Jay_se is correct. But I haven't tried that before. We also had this issue before and we solve that using DataGrid. We can used JavaScript get the HTML String of the GridView and do the same.
Regards, Venkatesh Mookkan. Software Engineer, India My: Website | Yahoo Group | Blog Spot
-
DKalepu wrote:
myGridView.RenderControl(htmlWrite);
You cannot render the GridView Control into HTML directly. Use DataGrid. May be Jay_se is correct. But I haven't tried that before. We also had this issue before and we solve that using DataGrid. We can used JavaScript get the HTML String of the GridView and do the same.
Regards, Venkatesh Mookkan. Software Engineer, India My: Website | Yahoo Group | Blog Spot
-
Hi,
Venkatesh MookkanYou cannot render the GridView Control into HTML directly.
We Can do Vankat. It works fine too.
Regards, Jay :)
If it works fine, then no problem for me man.. Thanks...
Regards, Venkatesh Mookkan. Software Engineer, India My: Website | Yahoo Group | Blog Spot
-
Hi All, I need some help. I'm trying to export Gridview into Excel. But i'm getting the following error! "Control 'myGridView' of type 'GridView' must be placed inside a form tag with runat=server." Here is my Code: protected void BtnExport_Click(object sender, EventArgs e) { Response.Clear(); Response.AddHeader("content-disposition", "attachment;filename=FileName.xls"); Response.Charset = ""; // If you want the option to open the Excel file without saving then // comment out the line below // Response.Cache.SetCacheability(HttpCacheability.NoCache); Response.ContentType = "application/ms-excel.xls"; System.IO.StringWriter stringWrite = new System.IO.StringWriter(); System.Web.UI.HtmlTextWriter htmlWrite = new HtmlTextWriter(stringWrite); myGridView.RenderControl(htmlWrite); Response.Write(stringWrite.ToString()); Response.End(); } THIS IS THE GRIDVIEW THAT I'M USING:: But my Gridview is already placed in the form only!!!!:((:confused: could any one please help me on
-
In order to overcome the error, We have to override the below function. public override void VerifyRenderingInServerForm(Control control) { }
Regards, Jay :)
Cool stuff man... I will rate this... :)
Regards, Venkatesh Mookkan. Software Engineer, India My: Website | Yahoo Group | Blog Spot
-
Cool stuff man... I will rate this... :)
Regards, Venkatesh Mookkan. Software Engineer, India My: Website | Yahoo Group | Blog Spot