0
Answer

Eliminating duplicates from datagrid

Photo of maria

maria

18y
2k
1
I have the following code but for some reason it adds some fields multiple times.

For Each row As DataRow In objTable.Rows

myTable.Columns("API").Unique = True

'objTable.Columns("API").Unique = True

apiValue = CStr(row.Item("API"))

matchedRows = myTable.Select("API = '" & apiValue & "'")

If matchedRows.Length > 0 Then

If Not apiList.Contains(apiValue) Then

apiList.Add(apiValue)

'dgResults.DataSource = apiList

dgResults.Rows.Add(apiValue)

End If

End If

Next