Problem calling RegisterStartupScript

Problem calling RegisterStartupScript

Hi,

I need to populate a javascript message box on saving data from the Gridview to the database.

I’m calling the RegisterStartupScript in the RowUpdate event as shown below.
But the problem is the Javascript doesn’t work.
I wanted the result of the confirmation message based on that, the changes will be saved into the database.

Any help?
Thanks in advance

 protected void GridView1_RowUpdated(object sender, GridViewUpdatedEventArgs e)
    {
        if (e.Exception != null)
        {
            string x = e.Exception.Message;
            Page.ClientScript.RegisterStartupScript(this.GetType(), "IsValid", "alert('" + x + "');", true);

        }
        else
        {
            myStringVariable = "Ok";
            Page.ClientScript.RegisterStartupScript(this.GetType(), "IsValid", "alert('" + myStringVariable + "');", true);
            GridViewBind();
        }
    }