I’ve been trying to find an answer online but I’m working with a DataTable and I want to filter all rows based on the column name in the table but I can’t seem to get the filterExpression to work. Even though the syntax is wrong, this is basically what I want it to do….
DataRow[] row = sqlDT.Select(ColumnName = “Foo”, “ASC”, DataViewRowState.CurrentRows);
Thanks so much.
There are a few ways to accomplish this. I would suggest using LINQ to filter the rows:
You can also use the
Selectmethod or theDefaultView.RowFilterproperty:EDIT
If you just want to filter out unneeded columns, use the
DefaultView.ToTable()method: