How can we Filter rows in a Datatable ?

 Posted by Pavanandey on 4/21/2010 | Category: ASP.NET Interview questions | Views: 31217

A filter condition can be specified on a datatable to filter row based on the condition specfied

datatable ="Condition");

Asked In: Many Interviews | Alert Moderator 

Comments or Responses

Posted by: Sheonarayan on: 5/8/2012 | Points: 10
This is wrong, the dataTable.Select returns the array of rows.

So your code should be

DataRow[] rows = dataTable.Select("expression");

In case you want to filter and keep the dataTable then write something like this

dataTable.DefaultView.RowFilter = "expression";


Login to post response