title: Error in datarow,Collection was modified; enumeration operation might not execute
body: <p>I have for-each loop in which the data row is updated so the exception ,<em>Collection was modified; enumeration operation might not execute</em> is generated. any way to fix it? i have seen To-List function but it is not working with data row , here is my code:</p>
  
  <pre><code>foreach (DataRow row in dataTable.Rows) {
    temp = row[0].ToString();
    foreach (DataRow rows in dataTable.Rows) {
      if (temp == rows[0].ToString()) {
        tempdatatable.Rows.Add(row[0],row[1]);
        dataTable.Rows.Remove(rows);
        //Update happens here
      }
      tempdatatable.DefaultView.Sort = "gscitations DESC";
      dataGridView1.DataSource = tempdatatable;
    }
  }
  </code></pre>