SelectRows

public static DataTable SelectRows(this DataTable dt, string whereExpression, string orderByExpression)
{
	dt.DefaultView.RowFilter = whereExpression;
	dt.DefaultView.Sort = orderByExpression;
	return dt.DefaultView.ToTable();
}
Example:
DataTable selection = dt.SelectRows("ID > 10", "Name");

Description

Wraps the usage of some DataTable.DefaultView properties to return sorted rows filtered on a custom filterexpression. For documentation on what to put in the whereExpression and the orderByExpression, refer to the MSDN documentation of DataTable.DefaultView.RowFilter and DataTable.DefaultView.Sort.

Details

Double click on the code to select all.

 

;