I'm using a gridview and a SqlDataSource
.
In the database, I've set a unique constraint on one of the columns.
When I'm changing the value of a cell from a row in the gridview with a new value but the value already exists in other row in the same column it gives me the error :
Cannot insert duplicate key row in object 'dbo.tb1' with unique index 'IX_tb1'.
The statement has been terminated.
I need to show a friendly message to the user for example in a label
Error: value already exists
Is there any way of doing this? Because I'm not using any sql command to catch something.
Thanks