title: Looping through each row in a datagridview
body: <p>How do I loop through each row of a <code>DataGridView</code> that I read in? In my code, the rows won't bind to the next row because of the same productID, so the <code>DataGridView</code> won't move to a new row. It stays on the same row and overwrites the price (for some products, I have two prices). How do I loop through each row to show the same productID but have a different price?</p>
  <p>EX : 1 Hamburger has 2 prices -- $1 and $2. After looping through the data, the result should have 2 rows with the same product but different pricing. How do I do this? Below is my code:</p>
  <pre><code>productID = odr[&quot;product_id&quot;].ToString();
  quantity = Double.Parse(odr[&quot;quantity&quot;].ToString());
  
  //processing data...
  key = productID.ToString();
  
  if (key != key_tmp)
  {
      //update index...
      i++;
  
      //updating variable(s)...
      key_tmp = key;
  }
  
  if (datagridviews.Rows[i].Cells[&quot;qty&quot;].Value != null) //already has value...
  {
      currJlh = Double.Parse(ddatagridviews.Rows[i].Cells[&quot;qty&quot;].Value.ToString());
  }
  else //not yet has value...
  {
      currQty = 0;
  }
  currQty += qty;
  
  //show data...
  datagridviews.Rows[i].Cells[&quot;price&quot;].Value = cv.toAccountingCurrency_en(Double.Parse(odr[&quot;item_price&quot;].ToString()));
  MessageBoxes.Show(i.ToString());
  MessageBoxes.Show(datagridviews.Rows[i].Cells[&quot;price&quot;].Value.ToString()); // in here there is two price that looped but won't showed in datagridviews
  </code></pre>