title: Search button on asp.net using C# codes
body: <p>I'm currently working on an activity where my Search button is not displaying my alert message when the user inputs last name that is not found in the database. It is already displaying the record if the last name is found on the database. and I'm planning to put a delete button when the record show. And I don't have any idea how to make it. just asking for a little hint. Thanks.</p>
  
  <pre><code>using (MySqlConnection con = new MySqlConnection(ConfigurationManager.ConnectionStrings["DBcon"].ConnectionString))
          {
              try
              {
                  con.Open();
                  string Sql = "SELECT * FROM contacts WHERE LastName LIKE '" + txtbx_search.Text + "%'";
  
                  MySqlDataAdapter da = new MySqlDataAdapter(Sql, con);
                  DataSet ds = new DataSet();
                  da.Fill(ds);
                  GridView1.DataSource = ds;
                  GridView1.DataBind();
              }
  
              catch (Exception)
              {
                  ClientScript.RegisterClientScriptBlock(this.GetType(), "alert", "alert('No record with that last name found!')", true);
              }
              finally
              {
                  con.Close();
              }
  </code></pre>