A: 

One thing I noticed right away is that the error message that your stored procedure is raising "Updation failed. record already exists" does not match the text string, "Updation failed. record Not exists", that you are checking in your try/catch block.

tchester
Thank You. But the catch block is not catching the error.
Geetha
+1  A: 

The Updating event is used to customize the SqlCommand being executed, but it does not execute the command. The try/catch block must wrap the actual place where the command is executed, not the customization callback.

Remus Rusanu
A: 

Hi all,

Thank You for all your replies.

By using a e.Exception in sqlDataSource_Updated my problem got solved.

protected void sqlDataSource_Updated(object sender, SqlDataSourceStatusEventArgs e)

{

if (e.Exception != null) { // If so, checks the Exception message if (e.Exception.Message == "Updation failed. Product already exists") { if (e.Exception != null)

            {

                // If so, checks the Exception message

                if (e.Exception.Message == "record already exists")

                {

                }

}

Geetha