title: System.InvalidCastException when work with datagridview
body: <pre><code>    private void VPfn_GenInvoice()
      {
          int iid = Convert.ToInt16(tid.Text);
          int cid = Convert.ToInt16(tcid.Text);
          double subtotal = Convert.ToDouble(tst.Text);
          double atax = Convert.ToDouble(tat.Text);
          double discount = Convert.ToDouble(tdis.Text);
          double total = Convert.ToDouble(ttotal.Text);
  
          StringBuilder iQ = new StringBuilder();
  
          foreach(DataRow x in invoice_data.Rows)
          {
              int iiid = VPfunctions.VPfn_N2ID_itm(x["item_name"].ToString());
              string dQuery = "INSERT INTO `invoice_data` (id, sr, item_id, item_qty, item_unit, item_vat, amount) " +
                  "VALUES(" + iid + ", " + x["serial_number"].ToString() + ", " + iiid + ", " + x["item_qty"].ToString()
                  + ", " + x["item_unit"].ToString() + ", " + x["item_vat"].ToString() + ", " + x["amount"].ToString() + ")";
              iQ.Append(dQuery);
              iQ.AppendLine();
          }
  
          //Updating main Invoice DB
          string query = "INSERT INTO `invoice` ( id, cusid, cdate, mdate, subtotal, atax, discount, total) VALUES (?A,?B,?C,?D,?E,?F,?G,?H)";
          xxtb.Text = iQ.ToString();
          /**
          try
          {
              //inserting into invoice
              con.Open();
              MySqlCommand xv = new MySqlCommand(query, con);
              xv.Parameters.AddWithValue("?A", iid.ToString());
              xv.Parameters.AddWithValue("?B", cid.ToString());
              xv.Parameters.AddWithValue("?C", DateTime.Now.ToString());
              xv.Parameters.AddWithValue("?D", "-");
              xv.Parameters.AddWithValue("?E", subtotal.ToString());
              xv.Parameters.AddWithValue("?F", atax.ToString());
              xv.Parameters.AddWithValue("?G", discount.ToString());
              xv.Parameters.AddWithValue("?H", total.ToString());
              xv.ExecuteNonQuery();
  
              //Inserting into invoice_data
              MySqlCommand ixv = new MySqlCommand(iQ.ToString(), con);
              ixv.ExecuteNonQuery();
          }
          catch
          {
  
          }
          finally
          {
              con.Close();
          } **/
      }
  </code></pre>
  
  <p>and I am getting error as follows:
  System.InvalidCastException: 'Unable to cast object of type 'System.Windows.Forms.DataGridViewRow' to type 'System.Data.DataRow'.'</p>
  
  <p>Now ,I am trying to make invoicing software for my own but I am getting this error and yes, I am using Visual studio 2017RC and windows 10 64bit.</p>