Friday, August 28, 2009

Remove a row from datatable

Below is the method to remove a row from datatable based on the conditions
Dim flag As Boolean = False
Dim dtTem As New DataTable
dtTem = dt.Clone()
dtTem.Clear()
' Dim dtrow As DataRow

For Each row As DataRow In dt.Rows
For Each col As DataColumn In dt.Columns
If row(col).ToString.Trim = "" Then
flag = True
ElseIf IsNumeric(row(col)) AndAlso CInt(row(col).ToString.Trim) = 0 Then
flag = True
Else
flag = False
Exit For
End If
Next
//If there is the data, add tht row to datatable
If flag = False Then
'dtrow = dtTem.NewRow()
'dtrow = row
dtTem.ImportRow(row)
End If
Next


Return dtTem

No comments:

Post a Comment