I want to filter a datatable with null values. I would prefer to use a linq query as the data table would have lots of rows.
The datatable looks something like this:
The column “Type” has dynamic values.
I only want to get the rows with null/no values in the “Type” column.
This is my linq query so far:
(From r In myDT.AsEnumerable
Where r("Type").toString.Contains("")
Select r).CopyToDataTable
My problem is, it doesn’t filter at all when i use Contains(“”), it just gets the whole datatable
but if I try Contains(“new1”), it works fine and filters all the rows with the “new1” value in the “Type” column
So I’m not sure how to filter the null values in the right way. Any help would be greatly appreciated.
You can use this query
TestDt.AsEnumerable.Where(Function(x) String.IsNullOrEmpty(x(“Type”).ToString.Trim) And x(“Type”).ToString.Trim.Equals(“new1”)).CopyToDataTable()