title: AJAX asp Web Forms search in grid
body: <p>I found implementation of my problem on a side but i dont know why it isn't working. When i put some value into textbox it should do me a postback but it does not.</p>
  
  <pre><code>&lt;asp:ScriptManager ID="ScriptManager1" runat="server" EnablePartialRendering="true" /&gt;
          &lt;div&gt;
              &lt;asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional"&gt;
                  &lt;Triggers&gt;
                      &lt;asp:AsyncPostBackTrigger ControlID="txt" /&gt;
                  &lt;/Triggers&gt;
                  &lt;ContentTemplate&gt;
                      &lt;asp:TextBox runat="server" ID="TextBox1" AutoPostBack="true" OnTextChanged="txt_TextChanged"&gt;&lt;/asp:TextBox&gt;
                      &lt;asp:GridView runat="server" ID="GridView2"&gt;
                          &lt;Columns&gt;
                              &lt;asp:BoundField DataField="Name" HeaderText="Name" SortExpression="Name" ItemStyle-Font-Size="10px" /&gt;
                              &lt;asp:BoundField DataField="regon" HeaderText="Regon" SortExpression="regon" ItemStyle-Font-Size="10px" /&gt;
                              &lt;asp:BoundField DataField="nip" HeaderText="NIP" SortExpression="nip" ItemStyle-Font-Size="10px" /&gt;
                          &lt;/Columns&gt;
                      &lt;/asp:GridView&gt;
                  &lt;/ContentTemplate&gt;
              &lt;/asp:UpdatePanel&gt;
          &lt;/div&gt;
  </code></pre>
  
  <p>And code behind :</p>
  
  <pre><code>protected void Page_Load(object sender, EventArgs e)
      {
          if (!IsPostBack)
          {
               txt.Attributes.Add("onkeyup", "javascript:setTimeout('__doPostBack(\'txt\',\'\')', 0)");
               string SelectCommand = "SELECT * " +
                   "  FROM client_inf WHERE amount &gt; 1000";
               conn.Open();
               OleDbDataAdapter da = new OleDbDataAdapter(SelectCommand, conn);
               DataSet ds = new DataSet();
               da.Fill(ds);
               GridView1.DataSource = ds.Tables[0];
               GridView1.DataBind();
               conn.Close();
          }
      }
       protected void txt_TextChanged(object sender, EventArgs e)
      {
          if (txt.Text != "")
          {
              string SelectCommand = "SELECT * " +
                   "  FROM client_inf WHERE client_name Like '" + txt.Text + "%'"
               conn.Open();
               OleDbDataAdapter da = new OleDbDataAdapter(SelectCommand, conn);
               DataSet ds = new DataSet();
              da.Fill(ds);
              GridView1.DataSource = ds.Tables[0];
              GridView1.DataBind();
              conn.Close();
          }
      }
  </code></pre>
  
  <p><a href="http://www.infosearchshop.com/21-gridview-search-as-you-type-with-ajax" rel="nofollow noreferrer">http://www.infosearchshop.com/21-gridview-search-as-you-type-with-ajax</a></p>