title: Filtering grid rows using Entity Framework
body: <p>I am relatively new to Entity Framework. I have learned how to manipulate data in EF and basics about databinding in gridviews and dropdowns using C#. But I simply can't filter records (rows) from table in database and bind them to grid. Below are few approaches I tried:</p>
  
  <p>To bind full table(this worked b-e-a-utifully)</p>
  
  <pre><code>em_dbEntities1 db = new em_dbEntities1();   //"em_dbEntities1" is the Database 
  gv_testef.DataSource = db.contacts ;        //"contact" is the table
  gv_testef.DataBind();                       //"gv_testef" is the gridview
  </code></pre>
  
  <p>TO EXTRACT A SINGLE ROW BASED ON CONDITION AND BIND THAT TO GRIDVIEW (THIS FAILED miserably)</p>
  
  <pre><code>em_dbEntities1 db = new em_dbEntities1();
  contact con = db.contacts.SingleOrDefault(p =&gt; p.id == 2);
  
  gv_testef.DataSource = con ;
  gv_testef.DataBind();
  </code></pre>
  
  <p>Second approach:</p>
  
  <pre><code>gv_testef.DataSource = db.contacts.SingleOrDefault(p =&gt; p.id == 2);
  </code></pre>
  
  <p>Again this failed.</p>
  
  <p>Kindly help in this regard.</p>