Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6099327
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T13:15:39+00:00 2026-05-23T13:15:39+00:00

I have a GridView and want to on an ASP.NET Web Application page and

  • 0

I have a GridView and want to on an ASP.NET Web Application page and want to export the data to excel.

Without UpdatePanels I worked perfectly with the following code:

        HttpContext.Current.Response.Clear();
        HttpContext.Current.Response.AddHeader(
            "content-disposition", string.Format("attachment; filename={0}", fileName));
        HttpContext.Current.Response.ContentType = "application/msexcel";

        using (StringWriter sw = new StringWriter())
        {
            using (HtmlTextWriter htw = new HtmlTextWriter(sw))
            {
                // The GridView stuff.
                // [...]

                //  render the htmlwriter into the response
                HttpContext.Current.Response.Write(sw.ToString());
                HttpContext.Current.Response.End();
            }
        }

With UpdatePanels this is no longer possible so I think I have to use a Generic Handler (*.ashx).

Is it somehow possible to pass the data to the generic handler without using session variables or is this the only way of doing this?

I also don’t want to phyiscally write the file on hdd because it’s only used one time by the user.

Any suggestions?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T13:15:40+00:00Added an answer on May 23, 2026 at 1:15 pm

    You can make a handler (ashx) which accepts a querystring, in the querystring you can put the filename of the download file. When you want to have security on the files (not all file are available for all users), you have to do some extra work in the querystring or put some info in the session on which files are available for download.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In web application [asp.net gridview], i want to display the gridvew without binding data,
I have a normal gridview on asp.net web page... I want to select a
I have a ASP.NET 1.1 web application page which is built with .net framework
I have a ASP.Net web page with a grid view. I want to filter
I have an ASP.NET Web Forms application. In my GridView OverviewGridView there is a
I'm using a GridView in ASP.NET web application and want to open something like
I have few controls on asp.net web form page and i want to link
I have a gridview in asp.net web page. The datasource comes sql server table.
I have an ambitious requirement for an asp.net 2.0 web page that contains a
I have an ASP.NET application inside which i have a GridView.I have Skin file

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.