Export Gridview to Excel

Posted on 2011-10-19
Last Modified: 2012-05-12
I am trying to export Gridview1 to Excel. I keep getting this error. Please see attachment.
Question by:VBdotnet2005
    LVL 17

    Accepted Solution

    Hello, maybe this can help you, at the top of your aspx file, set the EnableEventValidation="false", example:
    <%@ Page Language="vb" EnableEventValidation="false" %>
    LVL 12

    Expert Comment

    by:Ramkisan Jagtap

     Just set viewstate false
    //Turn off the view state
    this.EnableViewState = False;
    //Remove the charset from the Content-Type header
    Response.Charset = String.Empty;
    LVL 14

    Expert Comment

    by:Dustin Hopkins
    Why don't you try using the helper utility here:

    The above methods are fine, depending on the content that your page is displaying, disabling event validation can be a potential security risk.
    This helper class should prevent the need to Override VerifyRenderingInServerForm or turn off event validation.

    One modification you may want to make t the code provided is to disable paging as the code in its current form will only export the rows visible on the current page.

    Hope this helps,

    Author Comment


    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Join & Write a Comment

    In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
    In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
    Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
    Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

    746 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    17 Experts available now in Live!

    Get 1:1 Help Now