I have a Telerik RadGrid and trying to export the contents to Excel / CSV but depending upon what I do / try, get one of two errors and hoping someone could help.
Error 1: "Unhandled exception at line 15, column 9936 in http://localhost:4940/Telerik.Web.UI.WebResource.axd?"I get this error when trying to export the contents using the following ImageButton click event.....Protected Sub ImageButton1_Click(ByVal sender As Object, ByVal args As Web.UI.ImageClickEventArgs) Handles ImageButton1.Click
Try
Dim s As String = String.Empty
Dim exp As InvReport = New InvReport() s = exp.GenerateInvReport() Response.ClearContent()
Response.ContentType = "text/comma-separated-values"
Response.AddHeader( _
"content-disposition", _
"attachment; filename=" + _
"export.csv")
Response.Buffer = True
Response.Write(s)
Response.Flush() Catch ex As Exception
Response.Clear()
Response.Write(ex.ToString())
Response.Flush()
Response.End()
End Try Response.End()
End Sub
Error 2:When researching, I see that the Telerik Grid has a built in feature to allow you to export the grid's contents. However: this doesn't work either. When I try the following:RadGrid1.ExportSettings.ExportOnlyData = True
RadGrid1.ExportSettings.IgnorePaging = True
RadGrid1.ExportSettings.OpenInNewWindow = True
RadGrid1.MasterTableView.ExportToCSV()
It appears the grid is "exported", but instead of opening the "Open / Save" dialog box, it just shows the contents in the same window, just one big grid without any paging. It doesn't open a new window or anything.
Error 1: "Unhandled exception at line 15, column 9936 in http://localhost:4940/Telerik.Web.UI.WebResource.axd?"I get this error when trying to export the contents using the following ImageButton click event.....Protected Sub ImageButton1_Click(ByVal sender As Object, ByVal args As Web.UI.ImageClickEventArgs) Handles ImageButton1.Click
Try
Dim s As String = String.Empty
Dim exp As InvReport = New InvReport() s = exp.GenerateInvReport() Response.ClearContent()
Response.ContentType = "text/comma-separated-values"
Response.AddHeader( _
"content-disposition", _
"attachment; filename=" + _
"export.csv")
Response.Buffer = True
Response.Write(s)
Response.Flush() Catch ex As Exception
Response.Clear()
Response.Write(ex.ToString())
Response.Flush()
Response.End()
End Try Response.End()
End Sub
Error 2:When researching, I see that the Telerik Grid has a built in feature to allow you to export the grid's contents. However: this doesn't work either. When I try the following:RadGrid1.ExportSettings.ExportOnlyData = True
RadGrid1.ExportSettings.IgnorePaging = True
RadGrid1.ExportSettings.OpenInNewWindow = True
RadGrid1.MasterTableView.ExportToCSV()
It appears the grid is "exported", but instead of opening the "Open / Save" dialog box, it just shows the contents in the same window, just one big grid without any paging. It doesn't open a new window or anything.