troubleshooting Question

ASP.net Gridview Export to Excel, it works but bombs with large number of lines

Avatar of ramrodcar
ramrodcar asked on
.NET ProgrammingVisual Basic.NETEditors IDEs
2 Comments1 Solution3171 ViewsLast Modified:
I'm using this to export a gridview to excel, the problem being that once i hit over 10000 records or so, it doesn't change and just displays the gridview. is there a different way to do this? is there a limitation to the stringwriter or htmltextwriter class?
i need to export about 50k lines to excel, and the data has to be manipulated before output, otherwise i would just export it out of sqlserver.
Private Sub ExportGridView()
        Dim at As String = "attachment; filename=" & "TEST" & ".xls"
        Response.ClearContent()
        Response.AddHeader("content-disposition", at)
        Response.ContentType = "application/ms-excel"
        Dim sw As StringWriter = New StringWriter
        Dim htw As HtmlTextWriter = New HtmlTextWriter(sw)

        Dim frm As HtmlForm = New HtmlForm
        GridView1.Parent.Controls.Add(frm)
        frm.Attributes("runat") = "server"
        frm.Controls.Add(GridView1)
        frm.RenderControl(htw)

        'GridView1.RenderControl(htw)
        Response.Write(sw.ToString)
        Response.End()
    End Sub
ASKER CERTIFIED SOLUTION
Jeff Certain

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 2 Comments.
Start Free Trial
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 2 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