User-380105403 posted
I have installed the 3.5 SP1 beta.
I have put some code in the OnValidate handler to return some friendly error messages. The exception thrown on Insert/Update displays fine in the DynamicValidator.
Any of the errors thrown on Delete are not handled by the DynamicValidator and ends up as an unhandled exception.
partial void OnValidate(ChangeAction action)
{
if (action ==
ChangeAction.Insert || action ==
ChangeAction.Update)
{
RequisitionDataContext rdc =
new RequisitionDataContext();
var query =
from l in rdc.Locations.Where(x => x.LocationName == LocationName && x.LocationID != LocationID)
select l;
if (query.Count() > 0)throw
new ValidationException("A location already exists with this name. Please select another.");
}
if (action ==
ChangeAction.Delete)
{
RequisitionDataContext rdc =
new RequisitionDataContext();
var query =
from l in rdc.vwLocation_Items.Where(x => x.LocationID == LocationID &&
Convert.ToBoolean(x.Available) ==
true) select l;
if (query.Count() > 0)
throw new
ValidationException("You cannot delete a location which has items associated with it.");
var query2 = from l
in rdc.Users.Where(x => x.LocationID == LocationID)
select l;
if (query2.Count() > 0)
throw new
ValidationException("You cannot delete a location to which users are assigned.");
var query3 =
from l in rdc.User_Locations.Where(x => x.LocationID == LocationID)
select l;
if (query3.Count() > 0)throw
new ValidationException("You cannot delete a location which has users associated with it.");
Please try our latest runtime bits at:
http://www.codeplex.com/aspnet/Release/ProjectReleases.aspx?ReleaseId=14474. We had some issues in some of our Details/Insert templates that would immediately redirect back to the main list page even if an error had occured. The templates should be corrected
in the lastet release listed above. Let me know if it solves you problem.
Marked as answer byAnonymousThursday, October 7, 2021 12:00 AM
Please try our latest runtime bits at:
http://www.codeplex.com/aspnet/Release/ProjectReleases.aspx?ReleaseId=14474. We had some issues in some of our Details/Insert templates that would immediately redirect back to the main list page even if an error had occured. The templates should be corrected
in the lastet release listed above. Let me know if it solves you problem.
Marked as answer byAnonymousThursday, October 7, 2021 12:00 AM