Event is causing an error, but I can't catch the exception
Posted
by proudgeekdad
on Stack Overflow
See other posts from Stack Overflow
or by proudgeekdad
Published on 2010-04-22T21:10:35Z
Indexed on
2010/04/22
21:13 UTC
Read the original article
Hit count: 195
A developer has created a custom control in ASP.NET using VB.NET. The custom control uses a repeater. In certain scenarios, the rpt_ItemDataBound event is encountering a data error. My goal is rather than having the user see the yellow screen of death, give the user a friendlier error explaining exactly what the data error is. I figured I would be able to use a Try/Catch block as shown below throw the exception, however, it appears that the event has nowhere to be thrown to and stops executing at the "End Try" line.
Protected Sub rpt_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.RepeaterItemEventArgs) Handles rpt1.ItemDataBound, rpt2.ItemDataBound
Try
ProcessBadData...
Catch ex As Exception
Throw ex
End Try
End Sub
In VB.NET, I can find where the repeater's DataSource is being set, however, I can not find a DataBind event.
Any ideas how I can capture the exception in this ASCX control so I can report it to the user?
© Stack Overflow or respective owner