title: Filtering DataGridView without changing the datasource - null reference error
body: <p>I want to implement a simple quick search / aka Filter on data that is already loaded into DataGridView without altering the datasource.</p>
  
  <p>This is my simple UI:</p>
  
  <p><img src="https://i.stack.imgur.com/ZeLat.png" alt="enter image description here"></p>
  
  <p>This is how I tried to filter my data (based on answer <a href="https://stackoverflow.com/a/10049875/2332336">here</a>):</p>
  
  <pre><code>public partial class Form1 : Form
  {
      public Form1()
      {
          InitializeComponent();
      }
  
      private void Form1_Load(object sender, EventArgs e)
      {
          List&lt;Line&gt; myLines = new List&lt;Line&gt;()
          {
              new Line() { Sku = "VCF001", Qty = 1 },
              new Line() { Sku = "VCF002", Qty = 1 },
              new Line() { Sku = "VCF003", Qty = 1 },
          };
          dataGridView1.DataSource = myLines;
      }
  
      private void searchBox_TextChanged(object sender, EventArgs e)
      {
          (dataGridView1.DataSource as DataTable).DefaultView.RowFilter 
              = string.Format("Sku LIKE '%{0}%'", searchBox.Text);
      }
  }
  
  public class Line
  {
      public string Sku { get; set; }
      public int Qty { get; set; }
  }
  </code></pre>
  
  <p>When I started to type "VC" I am getting this error:</p>
  
  <blockquote>
    <p>System.NullReferenceException was unhandled   Message=Object reference
    not set to an instance of an object.</p>
  </blockquote>
  
  <p><img src="https://i.stack.imgur.com/Cdrhh.png" alt="enter image description here"></p>
  
  <p>How the quick search / filtering should work is like this:</p>
  
  <ul>
  <li>If I type "VC" it should show all 3 rows</li>
  <li>IF I type "VCF001" it should only show row having that sku</li>
  </ul>
  
  <p>Any idea what I am doing wrong here?</p>