Hi robertrack,
Here i have provided a sample code.
You need to add reference in the project by adding System.Windows.Forms than using the below namespace.
using message = System.Windows.Forms
C#
protected void OnRowDeleting(object sender, GridViewDeleteEventArgs e)
{
message.DialogResult result = message.MessageBox.Show("Do you want to delete this row ?", "", message.MessageBoxButtons.YesNo, message.MessageBoxIcon.Warning);
if (result == message.DialogResult.Yes)
{
int customerId = Convert.ToInt32(GridView1.DataKeys[e.RowIndex].Values[0]);
string constr = ConfigurationManager.ConnectionStrings["Constring"].ConnectionString;
using (SqlConnection con = new SqlConnection(constr))
{
using (SqlCommand cmd = new SqlCommand("Customers_CRUD"))
{
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@Action", "DELETE");
cmd.Parameters.AddWithValue("@CustomerId", customerId);
cmd.Connection = con;
con.Open();
cmd.ExecuteNonQuery();
con.Close();
}
}
}
this.BindGrid();
}