Collection was modified enumeration operation might not execute while adding a data row

I am getting collection was modified enumeration operation might not execute, while adding a Data Row.

I did see the forum help on delete a data table row. But it was not helpful for me, as I am trying to add a row.

Please help.

The error is because you are trying to modify the data table which you are looping and inside the loop itself. So, try doing it outside the loop @Rajalakshmi

Hi this was not the problem. I had read and write the data in the same data table. That has caused this error.

1 Like