/ Published in: VB.NET
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
Public Function DistinctRows_Int32_Key(ByVal dt As DataTable, ByVal keyfield As String) As DataTable Dim newTable As DataTable = dt.Clone Dim keyval As Int32 = 0 Dim dv As DataView = dt.DefaultView dv.Sort = keyfield If dt.Rows.Count > 0 Then For Each drv As DataRowView In dv '.ToTable.Rows If drv("mark") <> "PG" Then newTable.ImportRow(drv.Row) ElseIf Not drv.Item(keyfield) = keyval Then newTable.ImportRow(drv.Row) keyval = drv.Item(keyfield) End If Next Else newTable = dt.Clone End If Return newTable End Function