Selecting rows from DataTable without using Linq

DataRow(s) from DataTable can be selected without LINQ just by using DataTable.Select() method.

string searchExpression = null; 
searchExpression = "CategoryId=" + 2; 
DataRow[] SelectedDataRows = EmailAttachment.Select(searchExpression);

SelectedDataRows will have all rows where CategoryID is 2. An overload of Select also allows to select and sort results, for more details on it

please see http://msdn.microsoft.com/en-us/library/way3dy9w.aspx

Advertisements