troubleshooting Question

Export gridview directly to a server file without open/save dialog

Avatar of Joar
Joar asked on
.NET ProgrammingASP.NET
5 Comments1 Solution923 ViewsLast Modified:
I have this code for sending a gridview to excel, but the code sends it to the client with a open/save dialog box.
May I do some code change to save it directly to a server file without asking the client?

Response.Clear()
        Response.AddHeader("content-disposition", "attachment;filename=Normisjon.xls")
   
         Response.Charset = ""
         Response.Cache.SetCacheability(HttpCacheability.NoCache)
 
         Response.ContentType = "application/vnd.xls"
 
         Dim stringWrite As New System.IO.StringWriter()
         Dim htmlWrite As System.Web.UI.HtmlTextWriter = New HtmlTextWriter(stringWrite)
 
          gw.RenderControl(htmlWrite)
 
          Response.Write(stringWrite.ToString())
          Response.End()
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 5 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 5 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros