locked
Button Click Doesnt work after I export Gridview data to Excel. RRS feed

  • Question

  • Hi,

    I Have to button below my Gridview one is OK and second Is ExportToExcel.when I click on ExportToExcel it Export data to excel it works perfect but after it write data to Excel when response come back to the same page

    and when I click on OK button It doesnt work,OK button Event not working.

     

    The code I have write is:

     

    private void Export_to_Excel()
    {
            string style = @"<style> .xl36 {mso-style-parentTongue Tiedtyle0;mso-number-format:0;text-align:center;border:.5pt solid black;white-space:normal;} </script> ";
            GridView1.AllowPaging = false;
            // GridBind();
            // BindGrid();
            // PrepareGridViewForExport(GridView1);
            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/vnd.xls";
            System.IO.StringWriter stringWrite = new System.IO.StringWriter();
            System.Web.UI.HtmlTextWriter htmlWrite = new HtmlTextWriter(stringWrite);
            GridView1.RenderControl(htmlWrite);
            Response.Write(style);
            Response.Write(stringWrite.ToString());
            Response.End();
    }

     

     

    Thanks and regards

    Jayesh.

    • Edited by Mike Walsh FIN Tuesday, May 5, 2009 11:50 AM Urgent : removed from Title. These are forums. Wait for an answer. Or if its urgent for you ring MS Customer Support Services. Don't push us by "Urgent"s
    Tuesday, November 27, 2007 6:24 AM

All replies