title: Search / Filter ASP ListView Using LINQ
body: <p>I have a ListView on a page that uses a object data source.  I want to be able to add a search box to the page and only show the results that match the search query.  Does anyone have a good reference?  I'm using C#.</p>
  
  <pre><code>&lt;%@ Page Title="" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true"
      CodeFile="system.aspx.cs" Inherits="system" %&gt;
  
  &lt;asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="Server"&gt;
  &lt;/asp:Content&gt;
  &lt;asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="Server"&gt;
      &lt;asp:Label ID="LabelSearch" runat="server" Text="Search: " /&gt;
      &lt;asp:TextBox ID="TextSearchBox" runat="server" /&gt;
      &lt;asp:ImageButton ID="ButtonSearchBox" runat="server" ImageUrl="~/Styles/Images/Find.png"
          OnClick="ButtonSearchBox_Click" /&gt;&amp;nbsp;
      &lt;asp:Label ID="LabelSystemCount" runat="server" /&gt;
      &lt;asp:ListView ID="SystemList" runat="server" DataSourceID="SystemSource" DataKeyNames="SystemID"&gt;
          &lt;ItemTemplate&gt;
              &lt;tr id="row" runat="server" class='&lt;%# Container.DataItemIndex % 2 == 0 ? "row" : "altrow" %&gt;'&gt;
                  &lt;td&gt;
                      &lt;%# Eval("Name") %&gt;
                  &lt;/td&gt;
                  &lt;td&gt;
                      &lt;%# Eval("Acronym") %&gt;
                  &lt;/td&gt;
                  &lt;td&gt;
                      &lt;%# Eval("Description") %&gt;
                  &lt;/td&gt;
                  &lt;td&gt;
                      &lt;asp:ImageButton ID="ButtonEdit" runat="server" ImageUrl="~/Styles/Images/Edit.png"
                          ToolTip="Edit" OnClick="ButtonEdit_Click" /&gt;
                      &lt;asp:ImageButton ID="ButtonDelete" runat="server" ImageUrl="~/Styles/Images/Delete-Red-Cross.png"
                          ToolTip="Delete" CommandName="Delete" /&gt;
                  &lt;/td&gt;
              &lt;/tr&gt;
          &lt;/ItemTemplate&gt;
          &lt;LayoutTemplate&gt;
              &lt;table class="system"&gt;
                  &lt;tr&gt;
                      &lt;th&gt;
                          &lt;asp:LinkButton runat="server" Text="System Name" /&gt;
                      &lt;/th&gt;
                      &lt;th&gt;
                          &lt;asp:LinkButton runat="server" Text="Acronym" /&gt;
                      &lt;/th&gt;
                      &lt;th&gt;
                          &lt;asp:LinkButton runat="server" Text="Description" /&gt;
                      &lt;/th&gt;
                      &lt;th&gt;
                          &lt;asp:Label runat="server" Text="" /&gt;
                      &lt;/th&gt;
                  &lt;/tr&gt;
                  &lt;tr id="itemPlaceholder" runat="server" /&gt;
              &lt;/table&gt;
          &lt;/LayoutTemplate&gt;
      &lt;/asp:ListView&gt;
      &lt;asp:DataPager ID="SystemPager" runat="server" PageSize="10" PagedControlID="SystemList"&gt;
          &lt;Fields&gt;
              &lt;asp:NumericPagerField /&gt;
          &lt;/Fields&gt;
      &lt;/asp:DataPager&gt;
      &lt;asp:ObjectDataSource ID="SystemSource" runat="server" DataObjectTypeName="cipfinModel.System"
          DeleteMethod="Delete" SelectMethod="GetSystems" SelectCountMethod="SystemCount"
          TypeName="SystemDAO" InsertMethod="Insert" UpdateMethod="Update" EnablePaging="true" /&gt;
  &lt;/asp:Content&gt;
  </code></pre>