title: How to highlight search results in gridview using asp.net?
body: <p>I am using a search box to sort my gridview according to the search text. I want to highlight the matching text in the gridview entered into the textbox.
  This is my aspx page-</p>
  
  <pre><code>&lt;table&gt;
      &lt;tr&gt;
        &lt;td&gt;
           &lt;asp:TextBox ID="TextBox1" runat="server" Width="167px"&gt;
           &lt;/asp:TextBox&gt;
        &lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
         &lt;td&gt;
             &lt;asp:Button ID="Button1" runat="server" onclick="Button1_Click" 
                  Text="Submit" Width="116px" /&gt;
         &lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;asp:GridView ID="GridView1" runat="server"&gt;
          &lt;/asp:GridView&gt;
      &lt;/tr&gt;
  &lt;/table&gt;
  </code></pre>
  
  <h2>code behind</h2>
  
  <pre><code>public void bind()
  {
       dt = g1.return_dt("select  * from tbl1 where id is  not null  " 
             + Session["Name"] + "  order by  compname ");
       if (dt.Rows.Count &gt; 0)
       {
           adsource = new PagedDataSource();
           adsource.DataSource = dt.DefaultView;
           adsource.PageSize = 10;
           adsource.AllowPaging = true;
           adsource.CurrentPageIndex = pos;
           btnfirst.Enabled = !adsource.IsFirstPage;
           btnprevious.Enabled = !adsource.IsFirstPage;
           btnlast.Enabled = !adsource.IsLastPage;
           btnnext.Enabled = !adsource.IsLastPage;
           GridView1.DataSource = adsource;
           GridView1.DataBind();
       }
       else
       {
          GridView1.DataSource = null;
          GridView1.DataBind();
       }
  }
  
  protected void Button1_Click(object sender, EventArgs e)
  {
      if (TextBox1.Text != "")
      {
          Session["Name"] = string.Format("and  compname  like '%{0}%' or productcategory like '%{0}%' or country like '%{0}%'");
      }
      else
      {
           Session["Name"] = null;
      }
  }
  </code></pre>
  
  <p>Please guide me how can I do this.</p>