Filter datatable for Dynamic rows value

Hello community,
i want to keep rows which i will be providing through Datatable but this table contains some part of rows
For Example:
dt1:
image

dt2:
image

Output:
image
Note:dt1 will have dynamic rows, i want to keep rows of dt2 which contains the dt1 rows values in Dt2

Hi @Prateek_Pathak

Try this

dt2.AsEnumerable().Where(Function(row) dt1.AsEnumerable().Any(Function(r) row("Brand_ID").ToString.Contains(r("Brand_ID").ToString))).CopyToDataTable()

Input:

DT1

image

DT2

image

Output:

image

Regards,

One of many options

Assign Activity
dtResult =

(From d in dt2.AsEnumerable
Let mv = d("Brand_ID").toString
Where dt1.AsEnumerable.Any(Function (x) mv.Contains(x("Brand_ID").toString.Trim) )
Select r=d).CopyToDataTable

And also

thanks for the solution its woking fine.

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.