title: How to filter an asp:DataGrid
body: <p>How can I filter the results shown in an asp.net Datagrid?</p>
  
  <p>html</p>
  
  <pre><code>    &lt;asp:TextBox ID="SearchText" runat="server" OnTextChanged="UpdateFilter" /&gt;
      &lt;asp:DataGrid ID="gvProjList" runat="server" CellPadding="4" 
          ForeColor="#333333" GridLines="None" style="text-align: left" 
          Width="400px" AllowSorting="true"&gt;
          &lt;FooterStyle BackColor="#990000" Font-Bold="True" ForeColor="White" /&gt;
          &lt;PagerStyle BackColor="#FFCC66" ForeColor="#333333" HorizontalAlign="Center" /&gt;
          &lt;HeaderStyle BackColor="#990000" Font-Bold="True" ForeColor="White" /&gt;
      &lt;/asp:DataGrid&gt;
  </code></pre>
  
  <p>c#</p>
  
  <pre><code>    protected void Page_Load(object sender, EventArgs e)
      {
          if(!IsPostBack)
          {
              DataTable dt ....
              ....
              gvProjList.DataSource = dt;
              gvProjList.DataBind();
           }
       }
  
  
      protected void UpdateFilter(object sender, EventArgs e)
      {
          // ????
          // ViewState["LastFilter"] = SearchText.Text;
          // gvProjList.DataBind();
  
      }
  </code></pre>