I have a code to debug where I am attempting to export data in Excel. It works fine for smaller data but when data size increases to several thousands, I get 'Out of Memory exception'. My application is running on IIS 6.0. Any recommendations?
PS: The process usually fails when it takes more than 1.2 GB of memory (looking at the Task Manager)
Protected Overrides Sub Render(ByVal writer As System.Web.UI.HtmlTextWriter)
If (IsExportToCSV) Then
Response.Clear()
Response.ContentType = "application/vnd.ms-excel"
Response.ContentType = "a"
'Remove the charset from the Content-Type header.
Response.Charset = ""
'Turn off the view state.
Page.EnableViewState = False
Dim tw As System.IO.StringWriter
tw = New System.IO.StringWriter
Dim hw As HtmlTextWriter = New HtmlTextWriter(tw)
'Get the HTML for the control.
Me.GridView1.AllowPaging = False
Me.GridView1.DataBind()
Me.GridView1.EnableViewState = False
Me.GridView1.AutoGenerateEditButton = False
Me.GridView1.RenderControl(hw)
Response.Write(tw.ToString)
Response.Flush()
Response.End()
Else
MyBase.Render(writer)
End If
End Sub