Try Catch Question How Make it go to specific catch?

  • Thread starter Thread starter needin4mation
  • Start date Start date
N

needin4mation

I'm writing c# asp.net. I have a dataset loading when the page loads
and it has an itemdatabound event.

When there is an error in the itemdatabound event I get the catch in
the calling function, not the one that actually caused the error (the
ItemDataBound).

How do I do this correctly? Thank you.
 
Hi,


I'm writing c# asp.net. I have a dataset loading when the page loads
and it has an itemdatabound event.

Dataset does not have a ItemDataBound, are you refering to a DataGrid?
When there is an error in the itemdatabound event I get the catch in
the calling function, not the one that actually caused the error (the
ItemDataBound).

How do I do this correctly? Thank you.


No really understand what you are saying, if you do not have a try/catch in
the event handler (the one that is called when the event ) you will get it
in the method that called Datagrid.Bind() , is this what you are seeing?

If this is the case you are seeing the expected behavior.

cheers,
 
I think it might have been because my try catch was in an if
statement...I fixed it, but I am not sure how to reproduce the problem.
Thanks for your help.
 
post the code of the ItemDataBound event handler

What could happen is that you used a catch clause with a specific exception
and maybe you were getting another type of exception.

you only see the exception outside if it was throw outside your try/catch;
if the type is not compatible or if you use a throw inside your catch clause


cheers,
 
Back
Top