title: Insert Data to Database - LINQ
body: <p>There is some data in my <code>datagridview</code>. I want to insert all that data at once into database from <code>datagridview</code> using LINQ. But, it couldn't be inserted. </p>
  
  <p>Here is my code :</p>
  
  <pre><code>DetailTransaction dt = new DetailTransaction();
  
  for (int i = 0; i &lt; dataGridView1.Rows.Count; i++)
  {
      dt.TransactionID = labelID.Text;
      dt.ProductID = dataGridView1.Rows[i].Cells[0].Value.ToString();
      dt.Quantity = int.Parse(dataGridView1.Rows[i].Cells[4].Value.ToString());
  }
  
  dc.DetailTransactions.InsertOnSubmit(dt);
  dc.SubmitChanges();
  </code></pre>
  
  <p>Can anyone tell me what is the correct code? </p>