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

Discussion in 'ASP .Net' started by Anjan Bhowmik, Mar 17, 2008.

  1. 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.
    Anjan Bhowmik, Mar 17, 2008
    #1
    1. Advertising

  2. Anjan Bhowmik

    bruce barker Guest

    RE: How to trap "Input String is not in Correct format" Exceptions whi

    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)


    "Anjan Bhowmik" wrote:

    > 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.
    >
    >
    bruce barker, Mar 17, 2008
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Ahmed Moustafa
    Replies:
    5
    Views:
    29,986
    Chris Smith
    Jul 14, 2004
  2. Paul Miller
    Replies:
    3
    Views:
    1,007
    Alex Martelli
    Nov 12, 2003
  3. Sergei Shelukhin
    Replies:
    1
    Views:
    558
    Mark Rae
    Nov 12, 2006
  4. jobs
    Replies:
    0
    Views:
    1,598
  5. Earl Teigrob
    Replies:
    1
    Views:
    388
    Shravan
    Mar 1, 2004
Loading...

Share This Page