I am using telerik radgrid and binding the data to it. I have a separate button named 'Export To Excel'. When I click on that button it needs to
export all the records from the grid to excel. For huge datasets when I try to export it gives me out of memory exception error.
Is there anyway I can capture this exception error in my web page.
The function that I use to export to excel is below. I would like to capture that exception in the below function.
Could you please help me to achieve this.
Private Sub btnPrintAll_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnPrintAll.Click
Try
Dim radGridExport As RadGrid
If Me.Parent.Page.Title = "Database Circle Search" Then
strCallingPage = "CIR"
ElseIf Me.Parent.Page.Title = "Database Search" Then
strCallingPage = "SEA"
End If
If Not Session("MILUSER") Is Nothing Then
IsMilUser = CType(Session("MILUSER"), Boolean)
Else
IsMilUser = False ' If object not in session then make it false
End If
Dim blnfromSrchUsrCtl As Boolean = True
Dim blnfromCustGrid As Boolean = False
Dim blnFromPrintAll As Boolean = True
Dim startTick As Long = DateTime.Now.Ticks
Dim endTick As Long
Dim tick As Long
Dim milliseconds As Long
Dim microseconds As Long
strColOrder = ViewState("Column Order")
If Me.Parent.Page.Title = "Database Search" Then
Dim objPage As SearchDB
objPage = CType(MyBase.Page, Page)
If Not objPage Is No
objPage.CustomizeGridColumns(strColOrder, blnfromSrchUsrCtl)
Else
Exit Sub
End If
ElseIf Me.Parent.Page.Title = "Database Circle Search" Then
If Not IsMilUser Or Not IsEASearch Then
Dim objPage As CircleSearchDB
objPage = CType(MyBase.Page, Page)
If Not objPage Is Nothing Then
objPage.CustomizeGridColumns(strColOrder, blnfromSrchUsrCtl)
Else
Exit Sub
End If
End If
End If
radGridExport = CType(Me.FindControl("grdExport"), RadGrid)
If IsMilUser And strCallingPage = "CIR" And IsEASearch Then
radGridExport.ExportSettings.IgnorePaging = True
radGridExport.ExportSettings.OpenInNewWindow = True
radGridExport.ExportSettings.ExportOnlyData = True
radGridExport.MasterTableView.ExportToExcel()
Else
grdResult.MasterTableView.GetColumn("SEL").Display = False
grdResult.ExportSettings.IgnorePaging = True
grdResult.ExportSettings.OpenInNewWindow = True
grdResult.ExportSettings.ExportOnlyData = True
grdResult.MasterTableView.ExportToExcel()
If grdResult.MasterTableView.GetColumn("FRQ").Visible = True Then
grdResult.MasterTableView.GetColumn("FREQ").Visible = True
Else
grdResult.MasterTableView.GetColumn("FREQ").Visible = False
End If
End If
Catch ex As Exception
AFMCommonUtils.LogError(CType(Me.Session("User"), AFMBusinessLogicLayer.UserBL).USERNAME, "UsrSearchResult", "btnPrintAll_Click", ex.Message, ex.StackTrace)
ClearModuleTracker()
Response.Redirect("~/ErrorDisplay.aspx")
End Try
End Sub