How can we Filter rows in a Datatable ?

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

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

datatable =  datatable.select("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";


Thanks

Login to post response