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); } } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)