title: Filtering results in ASP.NET Web Forms
body: <p>I'm trying to walk through a tutorial on web forms, and my attempts to filter search results isn't working quite right:</p>
  
  <p>The contents of the asp page look like this:</p>
  
  <pre><code>&lt;form id="form1" runat="server"&gt;
  
  &lt;asp:TextBox ID="TextBox1" runat="server"&gt;&lt;/asp:TextBox&gt;
  &lt;asp:Button ID="button1" runat="server" onclick="button1_Click" Text="Submit" /&gt;
  &lt;asp:GridView ID="GridView1" AllowPaging="true" PageSize="8" AutoGenerateColumns="false" runat="server"
  OnPageIndexChanging="GridView1_PageIndexChanging"&gt;
  
     &lt;Columns&gt;
        &lt;asp:BoundField HeaderText="Qual ID" DataField="ID" /&gt;
        &lt;asp:BoundField HeaderText="Client Name" DataField="Client_Name" /&gt;
        &lt;asp:BoundField HeaderText="Project" DataField="Project_Name" /&gt;
        &lt;asp:BoundField HeaderText="Uploaded By" DataField="Uploaded_By" /&gt;
     &lt;/Columns&gt;
  
  &lt;/asp:GridView&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>And the code behind file:</p>
  
  <pre><code>public partial class Sample1 : System.Web.UI.Page
  {
  protected void Page_Load(object sender, EventArgs e)
  {
  
      SourceDataContext db = new SourceDataContext();
  
      GridView1.DataSource = from q in db.Cust
                             orderby q.ID
                             select q;
      GridView1.DataBind();
  }
  
  protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
  {
      GridView1.PageIndex = e.NewPageIndex;
  
      GridView1.DataBind();
  }
  protected void button1_Click(object sender, EventArgs e)
  {
      string client = TextBox1.Text;
  
      SourceDataContext db = new SourceDataContext();
  
      GridView1.DataSource = from q in db.Cust
                             where q.Client_Name == client
                             orderby q.ID
                             select q;
      GridView1.DataBind();
  
  }
  }
  </code></pre>
  
  <p>The filtering works, although it the paging stops working. Any suggestions appreciated.</p>
  
  <p>Thanks.</p>