title: Bind the Data to DataGridView in C#
body: <p>I have a table with <code>ID</code> and a <code>Name</code> column i want to show the one <code>ID</code> and <code>Name</code> in a <code>DataGridView</code> For Example in <code>Textbox</code> when i enter <code>ID</code> and click search button the datagridview shows the specifc record. In Search <code>Button</code> I have following Code but it gives error</p>
  
  <pre><code>con.Open();
  Sqlcommand cmd = new Sqlcommand("Select * from Registration where ID = '"+textBox1.Text+"'")
  sqldatareader reader = cmd.Executereader();
  if (reader.HasRows)
  {
            datagridview1.DataSource = reader.GetSqlValues()
   }
  </code></pre>
  
  <p>How can i bind the data to datagridview?</p>