Reputation: 13
I have datatable with column name tag and 100 rows of data.I need to filter this table with tag starting with "UNKNOWN".
What should my sortexpression for datatable.select be ?
I'm trying the following.
Datarow[] abc = null;
abc = dtTagList.Select(string.format("tag='{0}'","UNKNOWN"))
How can I achieve tag startswith 'UNKNOWN' in the above code ?
Upvotes: 1
Views: 712
Reputation: 204129
Well, obviously you don't need to pass in a sort expression - you want a filter expression.
According to the MSDN article on DataTable.Select, the expression you pass in obeys the same rules as the DataColumn.Expression property, which supports the LIKE operator.
So give this a whirl:
abc = dtTagList.Select("tag LIKE 'UNKNOWN%'");
Upvotes: 0