How to handle exceptions that occur in ObjectDataSource.Select ?

Discussion in 'ASP .Net Web Controls' started by Thomas, Sep 26, 2007.

  1. Thomas

    Thomas Guest

    Hi,

    I have a dataview and ObjectDataSource controls in an .aspx page. The
    ObjectDataSource has a SelectMethod with selectParameters collection. The
    DataView is bound to the objectdatasource with its property DataSourceID
    inside the aspx page (not dynamically in the code). I would like to handle
    properly an exception that occurs in SelectMethod of ObjectDataSource
    control. I put a try/catch block in the SelectMethod (the exception is just
    thrown with "throw;" instruction) but I don't figure how to catch it in
    ..aspx page where the dataview and the objectdatasource controls are
    declared. The selectMethod run once the dataview is bound to the
    objectdatasource but if an exception occurs the error page is displayed.
    Thanks in advance for your help.

    Regards,

    Thomas
    Thomas, Sep 26, 2007
    #1
    1. Advertising

  2. Thomas

    Phil H Guest

    On 26 Sep, 10:49, "Thomas" <> wrote:
    > Hi,
    >
    > I have a dataview and ObjectDataSource controls in an .aspx page. The
    > ObjectDataSource has a SelectMethod with selectParameters collection. The
    > DataView is bound to the objectdatasource with its property DataSourceID
    > inside the aspx page (not dynamically in the code). I would like to handle
    > properly an exception that occurs in SelectMethod of ObjectDataSource
    > control. I put a try/catch block in the SelectMethod (the exception is just
    > thrown with "throw;" instruction) but I don't figure how to catch it in
    > .aspx page where the dataview and the objectdatasource controls are
    > declared. The selectMethod run once the dataview is bound to the
    > objectdatasource but if an exception occurs the error page is displayed.
    > Thanks in advance for your help.
    >
    > Regards,
    >
    > Thomas


    Hi Thomas

    If you bind the object data to the visual control with the
    DatasourceID property then the error handling is outside your control
    for the standard events. You need to handle it within the Select
    method in your code rather than pass it up the chain with "Throw".
    Phil H, Sep 26, 2007
    #2
    1. Advertising

  3. Thomas

    Thomas Guest

    Thanks for your reply. I finally handled exceptions in Application_Error in
    global.asax. It was the easiest way for me to do it without modifying the
    code.

    Regards,

    Thomas


    "Phil H" <> a écrit dans le message de
    news:...
    > On 26 Sep, 10:49, "Thomas" <> wrote:
    >> Hi,
    >>
    >> I have a dataview and ObjectDataSource controls in an .aspx page. The
    >> ObjectDataSource has a SelectMethod with selectParameters collection. The
    >> DataView is bound to the objectdatasource with its property DataSourceID
    >> inside the aspx page (not dynamically in the code). I would like to
    >> handle
    >> properly an exception that occurs in SelectMethod of ObjectDataSource
    >> control. I put a try/catch block in the SelectMethod (the exception is
    >> just
    >> thrown with "throw;" instruction) but I don't figure how to catch it in
    >> .aspx page where the dataview and the objectdatasource controls are
    >> declared. The selectMethod run once the dataview is bound to the
    >> objectdatasource but if an exception occurs the error page is displayed.
    >> Thanks in advance for your help.
    >>
    >> Regards,
    >>
    >> Thomas

    >
    > Hi Thomas
    >
    > If you bind the object data to the visual control with the
    > DatasourceID property then the error handling is outside your control
    > for the standard events. You need to handle it within the Select
    > method in your code rather than pass it up the chain with "Throw".
    >
    Thomas, Sep 27, 2007
    #3
    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. Miguel Dias Moura
    Replies:
    4
    Views:
    452
    Hans Kesting
    May 6, 2004
  2. Mick
    Replies:
    0
    Views:
    430
  3. Ewan B
    Replies:
    0
    Views:
    560
    Ewan B
    Sep 26, 2003
  4. Afanasiy
    Replies:
    3
    Views:
    292
    Peter Hansen
    Nov 4, 2003
  5. David Thielen

    ObjectDataSource method as another ObjectDataSource

    David Thielen, Mar 21, 2006, in forum: ASP .Net Web Controls
    Replies:
    3
    Views:
    241
    Steven Cheng[MSFT]
    Mar 23, 2006
Loading...

Share This Page