ObjectDataSource and GridView - Handling Errors During DataBinding

Discussion in 'ASP .Net Web Controls' started by Mythran, Aug 6, 2009.

  1. Mythran

    Mythran Guest

    We have a class that contains the Fetch/Insert/Update/Delete methods that a
    DataObjectSource uses to fetch/insert/update/delete for a GridView control.
    The Fetch method accepts a single parameter which is a custom class used for
    building a search that is then transformed into SQL based on user-input.

    Inside the class containing the Fetch/etc. methods, the Fetch method may
    throw an exception because the user didn't enter anything in a search/fetch.
    The exception is a custom validation exception that notifies the user that
    they are required to enter at least one criteria field in order to perform
    the search. Is there an event, method, etc. that I can use on either the
    ObjectDataSource or GridView control classes to handle the error and display
    a message to the user instead of the page redirecting to the unhandled
    exception page?

    Thanks,
    Mythran
     
    Mythran, Aug 6, 2009
    #1
    1. Advertising

  2. Hi Mythran,

    >Is there an event, method, etc. that I can use on either the
    >ObjectDataSource or GridView control classes to handle the error and

    display
    >a message to the user instead of the page redirecting to the unhandled
    >exception page?


    You can handle the exception in the Selected event handler of
    ObjectDataSource. Like below:

    protected void ObjectDataSource1_Selected(object sender,
    ObjectDataSourceStatusEventArgs e)
    {
    if (e.Exception != null) {
    //handle exception
    e.ExceptionHandled = true;
    }
    }

    Please let me know if it works and feel free to ask if you have additional
    questions.

    Regards,
    Allen Chen
    Microsoft Online Support

    Delighting our customers is our #1 priority. We welcome your comments and
    suggestions about how we can improve the

    support we provide to you. Please feel free to let my manager know what you
    think of the level of service provided.

    You can send feedback directly to my manager at: .

    ==================================================
    Get notification to my posts through email? Please refer to
    http://msdn.microsoft.com/en-

    us/subscriptions/aa948868.aspx#notifications.

    Note: MSDN Managed Newsgroup support offering is for non-urgent issues
    where an initial response from the community

    or a Microsoft Support Engineer within 2 business day is acceptable. Please
    note that each follow up response may

    take approximately 2 business days as the support professional working with
    you may need further investigation to

    reach the most efficient resolution. The offering is not appropriate for
    situations that require urgent, real-time

    or phone-based interactions. Issues of this nature are best handled working
    with a dedicated Microsoft Support

    Engineer by contacting Microsoft Customer Support Services (CSS) at
    http://msdn.microsoft.com/en-

    us/subscriptions/aa948874.aspx
    ==================================================
    This posting is provided "AS IS" with no warranties, and confers no rights.
     
    Allen Chen [MSFT], Aug 7, 2009
    #2
    1. Advertising

  3. Mythran

    Mythran Guest

    "Allen Chen [MSFT]" <> wrote in message
    news:...
    > Hi Mythran,
    >
    >>Is there an event, method, etc. that I can use on either the
    >>ObjectDataSource or GridView control classes to handle the error and

    > display
    >>a message to the user instead of the page redirecting to the unhandled
    >>exception page?

    >
    > You can handle the exception in the Selected event handler of
    > ObjectDataSource. Like below:
    >
    > protected void ObjectDataSource1_Selected(object sender,
    > ObjectDataSourceStatusEventArgs e)
    > {
    > if (e.Exception != null) {
    > //handle exception
    > e.ExceptionHandled = true;
    > }
    > }
    >
    > Please let me know if it works and feel free to ask if you have additional
    > questions.
    >
    > Regards,
    > Allen Chen
    > Microsoft Online Support
    >
    > Delighting our customers is our #1 priority. We welcome your comments and
    > suggestions about how we can improve the
    >
    > support we provide to you. Please feel free to let my manager know what
    > you
    > think of the level of service provided.
    >
    > You can send feedback directly to my manager at: .
    >
    > ==================================================
    > Get notification to my posts through email? Please refer to
    > http://msdn.microsoft.com/en-
    >
    > us/subscriptions/aa948868.aspx#notifications.
    >
    > Note: MSDN Managed Newsgroup support offering is for non-urgent issues
    > where an initial response from the community
    >
    > or a Microsoft Support Engineer within 2 business day is acceptable.
    > Please
    > note that each follow up response may
    >
    > take approximately 2 business days as the support professional working
    > with
    > you may need further investigation to
    >
    > reach the most efficient resolution. The offering is not appropriate for
    > situations that require urgent, real-time
    >
    > or phone-based interactions. Issues of this nature are best handled
    > working
    > with a dedicated Microsoft Support
    >
    > Engineer by contacting Microsoft Customer Support Services (CSS) at
    > http://msdn.microsoft.com/en-
    >
    > us/subscriptions/aa948874.aspx
    > ==================================================
    > This posting is provided "AS IS" with no warranties, and confers no
    > rights.
    >


    I believe this is what I was looking for. Thank you.

    Mythran
     
    Mythran, Aug 11, 2009
    #3
  4. >I believe this is what I was looking for. Thank you.

    >Mythran


    You're welcome! Thank you for using our Newsgroup Support Service!

    Regards,
    Allen Chen
    Microsoft Online Community Support



    =================================================
    Delighting our customers is our #1 priority. We welcome your comments and
    suggestions about how we can improve the support we provide to you. Please
    feel free to let my manager know what you think of the level of service
    provided. You can send feedback directly to my manager at:
    .
    =================================================
     
    Allen Chen [MSFT], Aug 12, 2009
    #4
    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. Mark Goldin

    Errors, errors, errors

    Mark Goldin, Jan 17, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    956
    Mark Goldin
    Jan 17, 2004
  2. =?Utf-8?B?VHJhaWwgTW9uc3Rlcg==?=

    ObjectDataSource with Complex Objects and 2 way Databinding

    =?Utf-8?B?VHJhaWwgTW9uc3Rlcg==?=, Nov 3, 2005, in forum: ASP .Net
    Replies:
    5
    Views:
    7,150
    Esteban
    Jan 12, 2007
  3. Kevin Frey

    Handling Errors wrt ObjectDataSource

    Kevin Frey, Nov 7, 2006, in forum: ASP .Net
    Replies:
    2
    Views:
    556
    Kevin Frey
    Nov 8, 2006
  4. Replies:
    1
    Views:
    853
    =?Utf-8?B?QnJhZCBSb2JlcnRz?=
    Apr 18, 2007
  5. HEM

    Cell handling when databinding in a GridView

    HEM, Aug 23, 2005, in forum: ASP .Net Datagrid Control
    Replies:
    0
    Views:
    143
Loading...

Share This Page