HI Team,
I have a DT and need to filter the DT and by value of rows.
DT is look like below.
Template Name |
Name |
First Name |
Last Name |
City |
Test |
Yes |
Yes |
No |
Yes |
If Test value was Yes we have to Keep that columns and columns names I need.
How to do? Can any one give the solution please.
Thanks,
Chethan P
lrtetala
(Lakshman Reddy)
2
Hi @copy_writes
Can you try below Query
filteredColumns = String.Join(", ", DT.Columns.Cast(Of System.Data.DataColumn)().
Where(Function(col) DT.AsEnumerable().
Any(Function(row) row("Template Name").ToString() = "Test" AndAlso row(col.ColumnName).ToString() = "Yes")).
Select(Function(col) col.ColumnName))
Regards,
Is that Possible to Keep it in the Array format
lrtetala
(Lakshman Reddy)
6
Yes, How about the following?
DT.Columns.Cast(Of System.Data.DataColumn)().
Where(Function(col) DT.AsEnumerable().
Any(Function(row) row("Template Name").ToString() = "Test" AndAlso row(col.ColumnName).ToString() = "Yes")).
Select(Function(col) col.ColumnName).ToArray()
Output:

Regards,
system
(system)
Closed
7
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.