I am not sure how to diagnose this problem

I am not sure how to diagnose this problem

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


jspurlin posted on Friday, November 10, 2006

I have an app that uses permissions. I do not touch anything in the core framework, I create a permissions management system in the library project for the app.  The permissions are enumerated and the populate three list boxes:  PermissionCategory, AvailablePermissions, PermissionsAssignedToRole.

Here is something to note:  they do not use the csla:DataSource control: calls and databinding are handled in code behind.

Everything works as expected except for one thing: When I try to "select" a duplicate item from the listbox AvailablePermissions and add that permission to the PermissionsAssignedToRole listbox, stepping through the code works like the ProjectTracker example. 

In the PTracker project, if I create another role with an identical Id, the exception is thrown

if (!IsValid)
        throw new Validation.ValidationException(Resources.NoSaveInvalidException);
and control is returned to the page.

In my project the exception is thrown and then falls through to the next line of code which isn't handled

(both PTracker and my project throw this exception)
if (!IsValid)
        throw new Validation.ValidationException(Resources.NoSaveInvalidException);

(PTracker exits here and returns control and the error message to the page, my project then falls through and tries to execute this line, but the object is not valid)
 if (IsDirty)
   result = (T)DataPortal.Update(this);

The one obvious difference is that I calling and binding in the code-behind without use of the csla datasource. I am sure my implementation is not completely correct, and I was wondering is anyone would have advice how to handle this.

For example, testing if the item is valid before "if(IsDirty)" also throws an unhandled error.

Thank you,
John Spurlin

Copyright (c) Marimer LLC