Home All Groups Group Topic Archive Search About

How to handle exceptions that occur in ObjectDataSource.Select ?

Author
26 Sep 2007 9:49 AM
Thomas
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

Author
26 Sep 2007 8:05 PM
Phil H
Show quote
On 26 Sep, 10:49, "Thomas" <thomasv1***@hotmail.fr> 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".
Author
27 Sep 2007 7:27 AM
Thomas
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


Show quote
"Phil H" <goo***@philphall.me.uk> a écrit dans le message de
news:1190837124.516548.161510@n39g2000hsh.googlegroups.com...
> On 26 Sep, 10:49, "Thomas" <thomasv1***@hotmail.fr> 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".
>

AddThis Social Bookmark Button