How to get using linq only specific values from datatable


I have this datatable.
How can i use linq/lambda expression to get the values from DRAW_Cnt column, only for abc and save them in a list.
For exmaple for abc i have List = {“0”,“1”}

Hi @Andrei_Croitoru ,
Use below query"Code= 'abc'").CopyToDataTable()
(From p in dt.Select() where p("Code").Equals("abc") select p).ToArray.CopyToDataTable()


Give a try in

vals =

(From d in yourDatatableVar.asenumerable
Where d(yourcolnameorindex).tostring.trim.toupper.equals(“ABC”)
Select v=d(yourcolnameorindex).tostring.trim).distinct().tolist

This is not my question

Hi @Andrei_Croitoru,

DataTableGroupByToList.xaml (7.0 KB)

listVariable = (from x in dtInput.AsEnumerable.Where(function(x) x(“Code”).ToString.Trim.Equals(“abc”))Select Convert.ToString(x(“DRAW_Cnt”))).ToList


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