I am using a label to displays a message when insert is successful. I want to also be able to display error message when a user tries to insert a duplicate. So when insert fails, I want to display a message that you cannot insert duplicates instead of the long code page that is now showing.
I would like to see something like "John Doe is already in the database! or something similar. Something more user friendly.
Server Error in '/' Application.
Violation of PRIMARY KEY constraint 'PK__aspnet_U__AF2760AD06CD04F7'. Cannot insert duplicate key in object 'dbo.aspnet_UsersInRoles'.
The statement has been terminated.
Here is my code behind:
protected void FormView1_ItemInserted(object sender, FormViewInsertedEventArgs e)
{
SuccessMessage.Text = "User successfully added to the role!";
SuccessMessage.Visible = true;
}
Here i ...
Go to the complete details ...