ahmed sa

ahmed sa

  • NA
  • 289
  • 129k

How to change statment to accept (= and like) in same time

Aug 26 2014 7:37 AM
Hi guys i make dynamic filter in datagridview but i face proplem
when i using to search for number as example
555 and inside id three values as 555,5555,55555 it give me three value
but actually there are one value found so that i need to use equal =  with like statment in same time
are this possible my code as below:
 



private void searchgrid_TextChanged(List<field> fields)

 System.Data.DataView dv = ((System.Data.DataView)dataGridView1.DataSource); //
 _textFilters = ""; //reset filters











bool first = true; //to handle the " and "








foreach (field f in fields)




{




if (f.Value.Length > 0) //only if there is a value to filter for




{




if (!first) _textFilters += " and ";




_textFilters += f.Field + " like '%" + f.Value + "%'";








 first = false;




}
}
dv.RowFilter = _textFilters;




this.label1.Text = _textFilters;




}





Answers (2)