In my WebForms application I have a drop down list (DDL) with methods Method_DataBinding
and Method_DataBound
. When I open form with this DDL and it have some wrong data, it gives me an exception. I want to catch it but I can't understand, where to do it.
On the last line of method Method_DataBinding
there is no error and it don't reach Method_DataBound
, so error is somewhere between this methods. I can't understand where
<asp:DropDownList
ID="SomeId"
runat="server"
DataSourceId="SomeDsId"
OnDataBinding="Method_DataBinding"
OnDataBound="Method_OnDataBound" />
protected void Method_DataBinding()
{
}
// Here betwen this two methods I have error, can't catch it
protected void Method_DataBound()
{
}
CodePudding user response:
If you use a SqlDataSource
(EntityDataSource
similar) you can use the Updated
event:
protected void SomeDsId_OnUpdated(object sender, SqlDataSourceStatusEventArgs e)
{
if (e.Exception != null)
{
// handle here
}
}