Cancelling Databinding on a CslaDatasource

Cancelling Databinding on a CslaDatasource

Old forum URL: forums.lhotka.net/forums/t/1010.aspx


mtavares posted on Thursday, August 24, 2006

I was wondering if there is a way to stop the csla datasource control from databinding.  I have a case where when I get my business object, a security exception may be thrown, and rather than redirecting to another page, I would rather stop databinding, hide the detailsview that was supposed to bind to the object, and then display a validator with the error.  I have no problems catching the exception and displaying the error, but another exception gets thrown by the page, because the business object being set in the CslaDatasource's SelectObject event is nothing.  Is there any way to fix this without doing a redirect as is done in the ProjectTracker example?

Thanks,
Mike

david.wendelken replied on Thursday, August 24, 2006

Can you modify your SelectObject event handler to return an "empty" collection instead of a null one?

I had a similar problem when I started adding BO collections to datagrids on a wizard control.

I'm building in conditional logic into the wizard (i.e., some wizard steps will not be executed if they are not-applicable) but the not-applicable databinding was still taking place upon the initial page load.

Setting the controls to not-visible seemed to make a difference also.

Copyright (c) Marimer LLC