Click here to Skip to main content
15,069,665 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
C#
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
  {
    if (e.CommandName == "Edit")
    { 
      Response.Redirect("~/Form1.aspx?SrNo=" +  e.CommandArgument.ToString());
    }
    else if (e.CommandName == "Delete")
    {
      SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["MyConn"].ToString());
      con.Open();
      SqlCommand cmd = new SqlCommand();
      cmd.CommandText = "Delete from Rnd Where SrNo =" + e.CommandArgument.ToString();
      cmd.Connection = con;
      if (cmd.ExecuteNonQuery() > 0)
      {
        ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "Message", "alert('Record deleted');window.location.href='Form2.aspx';", true);
      }
      else
      {
        ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "Message", "alert('Record not deleted')", true);
      }
    }
  }


[edit]Code block added to preserve formatting - OriginalGriff[/edit]
Posted
Updated 14-Jan-11 23:51pm
v3
Comments
OriginalGriff 15-Jan-11 4:14am
   
Reason for my vote of 1: Please stop asking meaningless questions: "Is it right?" is not a lot of use when we do not know what you are trying to do.

No, this is not at all the code of event bubbling.

Would suggest you to read first, then try and then post specific issue if faced. :thumbsup:
   
Not a question, and removed "(Is it right)" from title. We can't tell you if your code is "right", because we don't have (nor do we want) all of your code. If it compiles, run it under the debugger. If it's not right, you'll know in short order.
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900