V
VB Programmer
Here's the code:
For Each li As ListItem In Me.lstAssignedEmailAddresses.Items
If li.Selected = True Then
Me.lstAssignedEmailAddresses.Items.Remove(li)
End If
Next
When I remove an item I get this error:
System.InvalidOperationException: Collection was modified; enumeration
operation may not execute. at
System.Collections.ArrayListEnumeratorSimple.MoveNext()
I think its because I'm changing the collection while trying to loop through
it.
Any ideas for a workaround?
Thanks.
For Each li As ListItem In Me.lstAssignedEmailAddresses.Items
If li.Selected = True Then
Me.lstAssignedEmailAddresses.Items.Remove(li)
End If
Next
When I remove an item I get this error:
System.InvalidOperationException: Collection was modified; enumeration
operation may not execute. at
System.Collections.ArrayListEnumeratorSimple.MoveNext()
I think its because I'm changing the collection while trying to loop through
it.
Any ideas for a workaround?
Thanks.