I have the following method to strip hidden and user-specified columns from a gridviewrow and return a tablerow.
Private Shared Function StripHiddenColumns(ByVal gvRow As GridViewRow, ByVal ColumnsToExclude() As Integer) As TableRow
Dim row As New TableRow
Dim i As Integer = 0
For Each cell As TableCell In gvRow.Cells
If cell.Visible Then
If Not ColumnsToExclude.Contains(i) Then
i += 1
Catch ex As Exception
However, when I run this code and hit the Add method for the TableRow, I get an InvalidOperationException stating the Collection was modified; enumeration operation may not execute. I've gotten this exception before, but usually it's because I'm attempting to modify a table that is databound. This particular one is not, i am creating it. Can anyone offer any insight?
Thanks in advance.
View Complete Post