I have the data table DtOperacoes, in this table I have 8 columns. I need to know if the index column 6 contains the value “901”, how could I do that? I tried to do it the following way: " DtOperacoes.Columns(6).ToString.Contains(“901”) "
But I think it’s not correct, could someone help me?
DtOperacoes.AsEnumerable.Where(function(x) x(6).ToString.Contains("901")).Count>0
- this check if any row contains 901 …if need to check equals that is whole value should be 901 for a cell then use equals instead of contains…
Cheers
I’m using this condition inside the IF, it’s returning me an error message Compiler error(s) encountered processing expression “DtOperacoes.AsEnumerable.Where(function(x) x(6).ToString.Contains(“901”))”. (2) : error BC30311: Value of type ‘EnumerableRowCollection(Of DataRow)’ cannot be converted to ‘Boolean’. main.xaml
Give a try with
DtOperacoes.AsEnumerable().Any(Function(row) row(6).ToString().Trim().Contains("901"))
Regards
Try this-
DtOperacoes.AsEnumerable().Any(Function(row) row(6).ToString() = “901”)
Thanks!!
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.