How to trap "Input String is not in Correct format" Exceptions while Databinding Gridview?

  • Thread starter Thread starter Anjan Bhowmik
  • Start date Start date
A

Anjan Bhowmik

I am getting this exception while binding data to Gridview. I have a control
parameter that accepts a integer value from a TextBox. If i provide a
invalid value, i get that exception. But can't handle it anywhere. I tried
the ObjectDataSource's Selecting method handler, but failed.

How do i cath those exceptions befor they rise?

And Can you please provide me a link that explains the "Event Mechanism" in
details, so that i gain acurate knowledge about how, and where i should
catch exceptions.

Thnx and Best regards.
 
the error is thrown during the databind:

try
{
grid.DataBind()
}
catch (Exception ex)
{
// do something with error
}

if you wnat the control to handle a bad parameter value and not throw an
error, then create a new control based on the existing control, and catch the
error in the property set.

-- bruce (sqlwork.com)
 
Back
Top