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

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.
 
B

bruce barker

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)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top