title: Search and filter on datagridview
body: <p>I'm load gridview to form using below function</p>
  
  <pre><code>private DataClasses1DataContext db_cooperations = new DataClasses1DataContext();
  private int numberOfObjectsPerPage = 20;
  private int CurrentPageIndex = 1;
  
  Func&lt;IEnumerable&lt;cooperations&gt;, IEnumerable&lt;cooperations&gt;&gt; ordering = t =&gt; t.OrderBy(i =&gt; i.name);
  
  private void daftarKoperasi_Load(object sender, EventArgs e)
  {
      GetData(CurrentPageIndex);
      dataGridProperty();
  }
  
   private void GetData(int page)
  {
      page = page - 1;
      db_cooperations.Log = Console.Out;  
  
      var query = (from c in ordering(db_cooperations.cooperations)
                  select new { c.id, c.name, c.phone, c.email, c.city })
                  .Skip(numberOfObjectsPerPage * page).Take(numberOfObjectsPerPage).ToList();
  
  
      dataGridView1.DataSource = query ;
  }
  </code></pre>
  
  <p>Then I want to search the data based on <strong>name</strong> and at the same time filtering the <strong>city</strong>. Any clue what should I do further?</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>So I update my code as follow</p>
  
  <pre><code>private void GetData(int page)
  {
      page = page - 1;
      db_cooperations.Log = Console.Out;  
  
      var query = (from c in ordering(db_cooperations.cooperations)
                  select new { c.id, c.name, c.phone, c.email, c.city })
                  .Skip(numberOfObjectsPerPage * page).Take(numberOfObjectsPerPage).ToList();
  
  
      if (String.IsNullOrEmpty(searchTxt.Text) == false)
      {
          query.Where(c =&gt; c.name.ToLower().Contains(searchTxt.Text.ToLower()));
      }
  
      if (cityCB.SelectedIndex &gt; -1)
          {
          query.Where(c =&gt; c.city.ToLower().Equals(cityCB.Text.ToLower()));
      }
  
      dataGridView1.DataSource = query ;
  }
  </code></pre>
  
  <p>But it still doesn't work</p>