RemoveVal.xaml (10.4 KB) I need to remove rows in a datatable based on list of values in another datatable.
From the Source Datatable, I need to remove entire rows if values in column “Col 2” matches with values found in column “Nos” in Datatbable DT1.
Please help me to solve this.
What I have:
and DT1 (it contains more than 1000 rows in actual data)
and what I need in new FinalDT
Since dealing with datatable with large data, I am trying in LinQ Query instead of For Each loop:
Please help me
You can create a list of all the values in the DT1 with the below LINQ
dtList = dt1.AsEnumerable().Select(Function (a) a.Field(Of String)(“Nos”).ToString).ToList()
And then you can use the below LINQ to create a new datatable having only the rows not present in DT1
FinalDT = SourceDT.AsEnumerable.Where(Function(row) Not dtList.Contains(row(“Col 2”).ToString)).CopyToDataTable
@Udhay Thanks for the reply.
It is working as expected.
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.