Catch ReportViewer Exception

Problem:

 I would like to know how I can catch errors that showup on my reportviewer web server control when for instance there is a parameter whose value was not set.

Solution:

You can you the ReportError method of the ReportViewer control. It has an 'e' argument of type ReportErrorEventArgs, which you can use to handle the error.

For example, I have a page where I use it like this:

Protected Sub ReportViewer1_ReportError(ByVal sender As Object, ByVal e As Microsoft.Reporting.WebForms.ReportErrorEventArgs) Handles ReportViewer1.ReportError 
If TypeOf e.Exception Is AspNetSessionExpiredException Then
e.Handled = True
Session.Abandon()
FormsAuthentication.SignOut()
Response.Redirect(FormsAuthentication.LoginUrl, True)
Else
e.Handled = False
End If
End Sub


from:

http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/Q_23871497.html

http://www.codeprof.com/dev-archive/90/6-75-908431.shtm

你可能感兴趣的:(exception)