I cant able to remove a row from a table while running through a loop
- by Vibin Jith
I am iterating through the table rows . if the row row is null I just want to remove the row.
it shows an error
Public Sub RemoveBlankRow(ByVal MyDataTable As DataTable)
Try
Dim MyRowStr As String = String.Empty
For Each MyRow As DataRow In MyDataTable.Rows
MyRowStr = ""
For Each MyCellText As Object In MyRow.ItemArray
MyRowStr = MyRowStr + MyCellText.ToString
Next
MyRowStr = Replace(MyRowStr, "0", " ")
MyRowStr = Replace(MyRowStr, ".", " ")
If MyRowStr.Trim = String.Empty Then
MyDataTable.Rows.Remove(MyRow)
End If
Next
Catch ex As Exception
End Try
End Sub
How to overcome this issue?