How to check if a data table row contains a specific value

Hi Everyone,

I want to check if my data table column contains any value.
Let’s say I have two columns.

Name Status
ABC 0
ZYZ 0
BCD 1
DSE 0
XYZ 1
BCA 0

I want to check if the “Status” column contains value “1”.
Also, If any row contain value “1”, get the value from corresponding column “Name” where ever the Status is “1”

Hi @Techno1

You can get the Name of all the Status=1 using this query:

requiredDt = yourDt.AsEnumerable.Where(Function(row) row("Status").ToString.Equals("1")).CopyToDatable

Edit: Output will be-

image

Hope this helps,
Best Regards.

1 Like

hasValue | Boolean =
YourDataTableVar.AsEnumerable.Any(Function (x) x(“Status”).toString.Trim.Equals(“1”))

is more a filter case which can be done with the different options to filter a datatable

OR
arrNames | String Array =

(From d in YourDataTable.AsEnumerable
Where d("Status").toString.Trim.Equals("1")
Select x = d("Name").toString.Trim).toArray
1 Like