Click here to Skip to main content
15,913,090 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello Friends
i am trying to export datagridview but its not work . here is my code..

C#
protected void BtnExcel_Click(object sender, ImageClickEventArgs e)
    {
        Response.Clear();
        Response.AddHeader("content-disposition", "attachment;filename=OrderReports.xls");
        Response.Charset = "";
        Response.ContentType = "application/vnd.xls";
        StringWriter sw = new StringWriter();
        HtmlTextWriter htw = new HtmlTextWriter(sw);
        GrdOrder.RenderControl(htw);
        Response.Write(sw.ToString());
        Response.End();

    }



code run successfully when i come to my website and see the inspect element then its give the error like this :-

Uncaught Sys.WebForms.PageRequestManagerParserErrorException: Sys.WebForms.PageRequestManagerParserErrorException: The message received from the server could not be parsed. Common causes for this error are when the response is modified by calls to Response.Write(), response filters, HttpModules, or server trace is enabled.
Details: Error parsing near '
Posted

1 solution

Got the Solution mySelf


Me just add this code in aspx page:-
XML
<Triggers>
            <asp:PostBackTrigger ControlID="BtnExcel" />
            <asp:PostBackTrigger ControlID="BtnWord" />
</Triggers>




Thank You all...!!
Have a nice day
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900