title: How to use searching from textbox and result show in gridview
body: <p>I am trying to fetch the matching database attribute from <code>textbox</code> text and display the related database in <code>GridView</code>. What am I doing wrong here?</p>
  
  <pre><code> protected void btnsearch_Click(object sender, EventArgs e)
   {
          string q = "Select * from facultyreg where fname ='"+txtsearch.Text.ToString() + "'";
          sda = new SqlDataAdapter(q, con);
          ds = new DataSet();
          sda.Fill(ds, "facultyreg");
          GridView2.DataSource = null;
          //GridView2.DataBind();
          GridView2.DataSource=ds.Tables[0];
  
         /* cmd = new SqlCommand(q,con);
          if (sdr.HasRows &amp;&amp; sdr != null)
          {
              sdr.Read();
  
          }*/
   }
  </code></pre>