I'm trying to export a gridview to excel. However, Internet Explorer constantly opens the file rather than giving me the choice to download it resulting in my computer slowing down signifigantly as it tries to load all the data. I've tried resetting both the security and advanced settings within IE and nothing seems to work, which leads me to think it might be my code.
Here is my export code:
Protected Sub On_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim TempAccessDataSource As New AccessDataSource
TempAccessDataSource.DataFile = strDatabasePath
TempAccessDataSource.SelectCommand = Session("SelectCommand")
Session("SelectCommand") = Nothing
'create table to export to excel
Dim NewGridView As New GridView()
NewGridView.DataSource = TempAccessDataSource
Dim oStringWriter As New System.IO.StringWriter()
Dim oHtmlTextWriter As New System.Web.UI.HtmlTextWriter(oStringWriter)
'export to excel
Response.Charset = ""
Response.ContentEncoding = System.Text.Encoding.ASCII
Response.Buffer = True
Response.ContentType = "application/vnd.ms-excel"
I appreciate any help on this matter as this problem is draining away my productivity.
I'm sorry if I put this question in the wrong topic area, I was unsure weather or not the problem lay in my code or with IE so I errored on the side of caution and placed it here.