title: How to hide or make it visible based on the condition given in the TextChanged event of the Textbox?
body: <p>I am having a textbox on my web form. Within this textbox I am using Jquery Auto Complete. I have taken two labels on my web form and trying to hide this label based on the condition I have given in the TextChanged event of the Textbox. But I am not able display the visible one.
  This is my aspx page-</p>
  
  <pre><code>&lt;link rel="stylesheet" href="//code.jquery.com/ui/1.10.4/themes/smoothness/jquery-ui.css"&gt;
    &lt;script src="//code.jquery.com/jquery-1.10.2.js"&gt;&lt;/script&gt;
    &lt;script src="//code.jquery.com/ui/1.10.4/jquery-ui.js"&gt;&lt;/script&gt;
    &lt;script type="text/javascript"&gt;
        $(function () {
        var items=[&lt;%=autotag %&gt;];
        $("#TextBox1").autocomplete({
        source:items
        });
        });
    &lt;/script&gt;
  &lt;table&gt;
  &lt;tr&gt;
  &lt;td&gt;Name:&lt;/td&gt;
  &lt;td&gt;
      &lt;asp:TextBox ID="TextBox1" runat="server" ontextchanged="TextBox1_TextChanged1" 
          AutoPostBack="True"&gt;&lt;/asp:TextBox&gt;&lt;/td&gt;
  &lt;/tr&gt;
     &lt;tr&gt;&lt;td colspan="2"&gt;
  &lt;asp:Panel ID="Panel1" runat="server" Visible="False"&gt;
      &lt;asp:Label ID="Label1" runat="server" Text=""&gt;&lt;/asp:Label&gt;
      &lt;br /&gt;
      &lt;asp:Label ID="Label2" runat="server" Text=""&gt;&lt;/asp:Label&gt;&lt;/asp:Panel&gt;
      &lt;/td&gt;&lt;/tr&gt;
  &lt;/table&gt;
  </code></pre>
  
  <p>My cs page-</p>
  
  <pre><code>public string autotag="";
  protected void Page_Load(object sender, EventArgs e)
  {
      if (IsPostBack == false)
      {
          bind1();
      }
  }
  </code></pre>
  
  <p>//This bind1() is for autocomplete.</p>
  
  <pre><code>public void bind1()
  {
  SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["MyConnection"].ConnectionString);
  con.Open();
  string query="select name from tbl_data_show";
  SqlCommand cmd=new SqlCommand(query,con);
  SqlDataReader dr=cmd.ExecuteReader();
  dr.Read();
  while(dr.Read())
  {
      if(string.IsNullOrEmpty(autotag))
      {
          autotag+="\""+dr["name"].ToString()+"\"";
      }
      else
      {
          autotag+=", \""+dr["name"].ToString()+"\"";
      }
  }
  }
  protected void TextBox1_TextChanged1(object sender, EventArgs e)
  {   
      SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["MyConnection"].ConnectionString);
      con.Open();
      SqlCommand cmd = new SqlCommand("select name from tbl_data_show where name='"+TextBox1.Text+"'", con);
      //DataTable dt1 = new DataTable();
      //SqlDataAdapter da = new SqlDataAdapter(cmd);
      //da.Fill(dt1);
      SqlDataReader dr = cmd.ExecuteReader();
      if (dr.HasRows)
      {
          while (dr.Read())
          {
              Panel1.Visible = true;
          }
      }
      else
      {
          Panel1.Visible = false;
      }
      con.Close();
  }
  </code></pre>
  
  <p>Please guide me where I am doing wrong?</p>