title: Additional information: Unable to cast object of type 'System.Windows.Forms.BindingSource' to type 'System.Data.DataTable'
body: <p>I'm having a weird issue with my code. I'm currently coding a filter for my datagrid.</p>
  
  <p>Whenever the user clears the text field - the following error message is brought up:</p>
  
  <blockquote>
    <p>Unable to cast object of type 'System.Windows.Forms.BindingSource' to
    type 'System.Data.DataTable'.</p>
  </blockquote>
  
  <p>This is my code so far:</p>
  
  <pre><code>    private void driverNo_TextChanged(object sender, EventArgs e)
      {
  
          // if driverNo text is empty then return all rows
  
          if (string.IsNullOrEmpty(driverNo.Text))
          {
              ((DataTable)dataGridView1.DataSource).DefaultView.RowFilter = string.Empty;
              return;
          }
  
          // if driverNo is a numerical value then view result
  
          int temp;
          if (int.TryParse(driverNo.Text, out temp))
              ((DataTable)dataGridView1.DataSource).DefaultView.RowFilter = "DriverNo = " + driverNo.Text;
          else
              MessageBox.Show("Invalid driver number.");
              driverNo.Text = "";
      }
  </code></pre>