title: How can I filter a DataGridView?
body: <p>I have created a simple <code>DataGridView</code> through the toolbox and have selected data through the wizard (no code in .cs file) from a database. It is working flawlessly as you can see in the picture below:
  <img src="https://i.stack.imgur.com/jM0iu.jpg" alt="DataGridView1" /></p>
  <p>Now I want to filter the entries in it by contact person name. I have a textbox and search button so when the user enters a &quot;contact person name&quot; such as &quot;Altaf&quot; and then clicks on search, the <code>GridView</code> should refresh and only entries with <code>ticketid=4</code> should appear.</p>
  <p>The only code in the .cs file (which is auto-generated) is:</p>
  <pre><code>private void Form2_Load(object sender, EventArgs e)
  { 
      this.tblTicketDetailTableAdapter.Fill(this.sTDataSet1.tblTicketDetail); //auto-generated
  }
  </code></pre>
  <p>I tried this in a <code>ButtonClick</code> event as suggested by someone but it generates the error: <code>&quot;Cannot interpret token '{' at position 27&quot;</code></p>
  <pre><code>BindingSource bs = new BindingSource();
  bs.DataSource = dataGridView1.DataSource;
  bs.Filter = issuerNameDataGridViewTextBoxColumn + &quot;like '%&quot; + txtbxSearch.Text.Trim().Replace(&quot;'&quot;, &quot;''&quot;) + &quot;%'&quot;;
  dataGridView1.DataSource = bs.DataSource;
  </code></pre>
  <p>I have no experience in <code>DataGridViews</code> or WinForms coding, so please explain in detail.</p>