Filter DataSet/DataTable Data

Method 1 for filtering DataSet/DataTable data 
 

 ds.Tables[0].DefaultView.RowFilter = "name ='"+textBox1.Text+"'";
 DataTable dt = ds.Tables[0].DefaultView.ToTable();
 dataGridView1.DataSource = dt;
 
方法二: 

 Select()
 Select(string filterExpression)
 Select(string filterExpression, string sort)
 Select(string filterExpression, string sort, DataViewRowState record States).
 
 1) Select() - Gets an array of all System.Data.DataRow objects.
 2) Select(string filterExpression) - Gets an array of all System.Data.DataRow objects that match the filter criteria in primary key order (or in addition order if there is no primary key).
 3) Select(string filterExpression, string sort) - Gets an array of all System.Data.DataRow objects that match the filter criteria in the specified sort order.
 4) Select(string filterExpression, string sort, DataViewRowState recordStates) - Gets an array of all System.Data.DataRow objects that match the filter in the sort order and the specified state.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324999265&siteId=291194637