M
Mike Mattix
I have an issue of attempting to Delete the DataRowViews from a
DataView. I have created a RowFilter to restrict the DataRowViews to
the group that I want to delete. When I delete the DataRowViews in a
for-next loop I get an error that a row does not exist in Pos n where n
seems to be half of the total number of DataRowViews in the DataView.
Example
dim dv as DataView
dim drv as DataRowView
dim dt as DataTable
dv = New DataView(dt)
dv.RowFilter = "Some Filter"
for each drv in dv
drv.Delete
next
It seems as though the enumeration of DataRowViews breaks down when you
delete a member from the DataView. ie:
row 0 - Pos 0
row 1 - Pos 1
row 2 - Pos 2
row 3 - Pos 3
Delete first row (row 0 - enumerator:0)
row 1 - Pos 0
row 2 - Pos 1
row 3 - Pos 2
Delete next row (row 2 - enumerator:1)
row 1 - Pos 0
row 3 - Pos 1
Delete next row (throws exception - enumerator:2)
I guess I could get the count and create a for loop to negatively
iterate through the items but isn't there an better(easier) way???
Thanks for ANY assistance.
Mike Mattix
DataView. I have created a RowFilter to restrict the DataRowViews to
the group that I want to delete. When I delete the DataRowViews in a
for-next loop I get an error that a row does not exist in Pos n where n
seems to be half of the total number of DataRowViews in the DataView.
Example
dim dv as DataView
dim drv as DataRowView
dim dt as DataTable
dv = New DataView(dt)
dv.RowFilter = "Some Filter"
for each drv in dv
drv.Delete
next
It seems as though the enumeration of DataRowViews breaks down when you
delete a member from the DataView. ie:
row 0 - Pos 0
row 1 - Pos 1
row 2 - Pos 2
row 3 - Pos 3
Delete first row (row 0 - enumerator:0)
row 1 - Pos 0
row 2 - Pos 1
row 3 - Pos 2
Delete next row (row 2 - enumerator:1)
row 1 - Pos 0
row 3 - Pos 1
Delete next row (throws exception - enumerator:2)
I guess I could get the count and create a for loop to negatively
iterate through the items but isn't there an better(easier) way???
Thanks for ANY assistance.
Mike Mattix