title: How to compare the rows of two tables and delete only if no matching row
body: <p>I want to be able to delete a row in gridview1 if there are no rows in gridview2 which has exactly the same values as gridview1</p>
  
  <p>What should I put in onRowDeleting?</p>
  
  <pre><code>protected void OnRowDeleting(object sender, GridViewDeleteEventArgs e)
  {
      string strConnString = ConfigurationManager.ConnectionStrings["ConnStr"].ConnectionString;
      SqlConnection con = new SqlConnection(strConnString);
      DataTable dt = new DataTable();
  
      using (SqlConnection conn = new SqlConnection(strConnString))
      {
  
  
        int selectedRow = e.RowIndex;
  
        GridViewRow theRow = GridView1.Rows[selectedRow];
        string str = ("Delete TDLoanRate where Id=@id");
        SqlCommand insert = new SqlCommand(str, con);
  
        insert.Parameters.AddWithValue("@id", Convert.ToInt32(theRow.Cells[0].Text));
  
        using (SqlDataAdapter sda = new SqlDataAdapter())
        {
             insert.Connection = con;
             con.Open();
             sda.SelectCommand = insert;
             sda.Fill(dt);
             GridView1.DataSource = dt;
             GridView1.DataBind();
        }
  </code></pre>