How to use Select method of DataTable

Yes, this works. For a list of all possible expressions see

Here also is a sample program demonstrating this works.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;

namespace ConsoleApplication2
    class Program
        static void Main(string[] args)
            DataTable table = new DataTable();

            // Create the first column.
            DataColumn textColumn = new DataColumn();
            textColumn.DataType = System.Type.GetType("System.String");
            textColumn.ColumnName = "text";

            // Create the second column.
            DataColumn priceColumn = new DataColumn();
            priceColumn.DataType = System.Type.GetType("System.Decimal");
            priceColumn.ColumnName = "price";
            priceColumn.DefaultValue = 50;

            // Add columns to DataTable.

            DataRow row = table.NewRow();
            row["text"] = "bc";

            DataRow[] rows = table.Select("text not like 'a%'");

Browse More Popular Posts

Leave a Comment