25 Feb 2012

DataTable Sort and Filter

public static DataTable SelectRows(this DataTable dt, string whereExpression, string orderByExpression)
{
    dt.DefaultView.RowFilter = whereExpression;
    dt.DefaultView.Sort = orderByExpression;
    return dt.DefaultView.ToTable();
}

No comments:

Post a Comment