Search code examples
c#selectdatatablesubstring

Substring test within DataTable.Select()


I have a DataTable with results already pulled down from a back end. I want to do a DataTable.Select(), but the criteria is based on a SUBSTRING of one of the columns.

Is there syntax to use in the Select() method that allows for substring of a column test, or do I have to do it the hard way -- scan each row.


Solution

  • You can use the LIKE operator in the expression given to Select():

    table.Select("ItemName LIKE '*product*'")