Click here to Skip to main content
12,757,627 members (38,036 online)
Rate this:
Please Sign up or sign in to vote.
See more: ASP.NET
i want to download gridview data to excel but i am getting error like this [System.Threading.ThreadAbortException] = {Unable to evaluate expression because the code is optimized or a native frame is on top of the call stack.}

here is code ..please tell me anyone
string filename = "DownloadMobileNoExcel.xls";
                                System.IO.StringWriter tw = new System.IO.StringWriter();
                                System.Web.UI.HtmlTextWriter hw = new System.Web.UI.HtmlTextWriter(tw);
                                GridExcelDetails.DataSource = GetTSubscriberDetails;
                                //Get the HTML for the control.
                                //Write the HTML back to the browser.
                                //Response.ContentType = application/;
                                Response.ContentType = "application/";
                                Response.AppendHeader("Content-Disposition", "attachment; filename=" + filename + "");
                                this.EnableViewState = false;

public override void VerifyRenderingInServerForm(Control control)

Posted 11-Dec-12 3:30am
Updated 11-Dec-12 3:32am
Tioned 4-Apr-16 8:23am

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

    Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170217.1 | Last Updated 11 Dec 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100