title: When i click the Add button to the gridview then the following code add the double record
body: <p>When I click the Add button to the grid view then the following code add the double record...</p>
  
  <pre><code>int drow;
  
  private void btn_poyeeNew_Click(object sender, EventArgs e)
  {
      drow = Dg.Rows.Add();
      Dg.Rows[drow].Cells[0].Value = txtPayee.Text;
  }
  
  public void showdatainGridview()
  {
      try 
      {
          SqlConnection con = new SqlConnection(HrGlobal.DbCon);
          query = "select payee_name from Tbl_payee";
          SqlDataAdapter sda = new SqlDataAdapter(query, con);
          DataTable dt = new DataTable();
          sda.Fill(dt);
          drow = 0;
          if(dt.Rows.Count &gt; 0)
          {
              foreach (DataRow row in dt.Rows)
              {
                  drow = Dg.Rows.Add();
                  Dg.Rows[drow].Cells[0].Value = row["payee_name"].ToString();
              }
          }
      }
      catch(Exception ex)
      {
          MessageBox.Show(ex.Message);
      }
  }
  
  private void PayeeBook_Load(object sender, EventArgs e)
  {
      showdatainGridview();
  }
  </code></pre>