Error Msg : Collection was modified: enumeration operation may not execute
Good day.
I have a datagrid which supposed to receive data input from user and when the user click on Save button, i use the function as below, to iterate throw each datarow and manually append it into db.
For Each objDR In tblUserGroupAdd.Rows
objUserGroup = New My.BusinessFacade.UserGroup
Select Case objDR.RowState
Case DataRowState.Added
objUserGroup.append(objDR("description", DataRowVersion.Default), objDR("remarks", DataRowVersion.Default), Nothing)
tblUserGroupAdd.RemoveTbl_User_GroupRow(objDR)
Case Else
End Select
Next
Upon success, teh datarow will be removed or else, it will remain in the datagrid.
But, when I try to exec the program, it return the error message "Collection was modified: enumeration operation may not execute".
What happen ? Is there any better way to code the same thing instead of the function I am using now ?
Thanks.
SonicWave :p