Last post Jan 12, 2011 07:14 PM by sjnaughton
Jan 10, 2011 05:11 PM|hnarisetty|LINK
When I delete a record from list screen, I get unhandled exception if this record key is used in other tables as forign key. The error is correct and it is working as it supposed to work. But How to I propagate back to user to display a meaningful message?
Jan 10, 2011 11:30 PM|sargamlucy|LINK
If you want to show a user friendly message to the user, then create a function for calling your procedure to delete the selected record. Allow the function to catch the exception, there you can get the error message for the exception. Return that to your
calling function or event, manipualte that message according to the error number or the message itself. And then you can either put alert box or show an error label, whose text you can put as "You can not delete record, as it might be used in other place."
Jan 11, 2011 12:25 AM|mayur.unagar|LINK
It depends upon what you want to achive.
First case, if you want to delete records from PK table and FK table then,
You should call the stored procedure for deleting entries from primary key master and Detailed FK table.
When user try to delete any record then you should first try to delete records from FK table based on Id and then try to delete records from PK table
and If there is any error occurred during deleting record, you should display some error message.
Second Case, If you don't want to allow user to delete FK table records based on PK table then just handle the error and display message like
"you are not allowed to delete this record, You should first delete matching records......"
Mark as answer if it helps you.
Jan 12, 2011 08:12 AM|sjnaughton|LINK
Hi Hari, first of all wich version of DD are you running and which entity model? once I know these I should be able to point you in the right direction.
Dynamic Data 4
Jan 12, 2011 09:28 AM|atulthummar|LINK
As per my suggestion Message Will Be :
"Sorry,you are not allowed to delete this record, Because It is used with Other resources(USERs)"
Jan 12, 2011 04:24 PM|hnarisetty|LINK
I am using VS2010, EF 4.0, DD 4.0
Jan 12, 2011 07:14 PM|sjnaughton|LINK
see How to add business logic to DD using EF4 I answered that here.
Dynamic Data 4