Posted By

krisdb on 01/29/09


Tagged

c-sharp


Versions (?)

Who likes this?

2 people have marked this snippet as a favorite

leonbda
umang_nine


RowFilter


 / Published in: C#
 

  1. private string RowFilter(string field, string keywords)
  2. {
  3. string output = String.Empty;
  4.  
  5. String[] straKeywords = keywords.Split(' ');
  6. int arrayLength = straKeywords.Length - 1;
  7.  
  8. int i = 0;
  9. foreach (string keyword in straKeywords)
  10. {
  11. output += String.Format("([{0}] LIKE '%{1}%')", field, keyword);
  12.  
  13. if (i++ < arrayLength)
  14. output += " OR ";
  15. }
  16.  
  17. return output;
  18. }

Report this snippet  

You need to login to post a comment.