title: Filter Datagridview rows using TextBox
body: <p>I have a binded datagridView and i want to filter it using a TextBox value.</p>
  
  <p>I used this code:</p>
  
  <pre><code>private void ChercheStextBox_TextChanged(object sender, EventArgs e)
      {
          try
          {
              ((DataTable)dataGridView3.DataSource).DefaultView.RowFilter = string.Format("LibService like '%{0}%'", ChercheStextBox.Text.Trim().Replace("'", "''"));
          }
          catch
          {
  
          }
  
      }
  </code></pre>
  
  <p>But this code doesn't filter the datagridView even i have used the same code </p>
  
  <p>in another datagridView and it works perfectly. I don't know where is the </p>
  
  <p>error in my code?</p>
  
  <p>Thanks in advance.</p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>i removed try catch and i got this error message:</p>
  
  <blockquote>
    <p>unable to cast object of type 'system.windows.forms.bindingsource' to type 'system.data.datatable'</p>
  </blockquote>
  
  <p>How can i fix it??</p>