How to handle exceptions that occur in ObjectDataSource.Select ?

T

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
 
P

Phil H

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".
 
T

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top