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

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Anjan Bhowmik

    #1

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

    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 ObjectDataSourc e'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.

  • =?Utf-8?B?YnJ1Y2UgYmFya2Vy?=

    #2
    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 ObjectDataSourc e'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.
    >
    >

    Comment

    Working...