title: How to filter a list on asp.netcore project
body: <p>I'm sorry in advance for what will probably be not explained well (I just started programming so i'm still new with the phrases and all).</p>
  
  <p>I have an asp.netcore application , in which I'm showing a list of all the agents in the company , which is fetched from the DB using controller:</p>
  
  <pre><code>ViewData["Agents"] = new SelectList(_context.Agent.OrderBy(x =&gt; x.FullName), "Id", "FullName");
  </code></pre>
  
  <p>I'm then displaying the data in a View :</p>
  
  <pre><code> &lt;div class="col-md-10"&gt;
       &lt;select asp-for="AgentId"  class ="form-control"  asp-items="ViewBag.Agents"  &gt;&lt;/select&gt;
   &lt;/div&gt;
  </code></pre>
  
  <p>This code works properly , but i want to allow the users to filters the agent name, so they won't have to search the entire list . I'm trying to look for a way on the internet but can find any (probably I'm not using the correct search words)</p>
  
  <p>Thanks.</p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>My agent class(the action part):</p>
  
  <pre><code>public class AgentAggrementChangeRequestsController : Controller
  {
      private readonly SabresContext _context;
      .......
  
      // GET: AgentAggrementChangeRequests
      public async Task&lt;IActionResult&gt; Index(string SearchString)
      {
          var sabresContext = _context.AgentAggrementChangeRequest.Include(a =&gt; a.Agent);
          ViewData["Agents"] = new SelectList(_context.Agent.OrderBy(x =&gt; x.FullName), "Id", "FullName");
  
  
          return View(await sabresContext.ToListAsync());
      }
  
      .....
  </code></pre>
  
  <p>And the view:</p>
  
  <pre><code>&lt;h2&gt;חדש&lt;/h2&gt;
  &lt;form asp-action="Create"&gt;
      &lt;div class="form-horizontal" &gt;
          &lt;h4&gt;תנאי הסכם סוכן חדש&lt;/h4&gt;
          &lt;hr /&gt;
          &lt;div asp-validation-summary="ModelOnly" class="text-danger"&gt;&lt;/div&gt;
              &lt;label asp-for="AgentId" class="col-md-2 control-label"&gt;סוכן&lt;/label&gt;
              &lt;div class="col-md-10"&gt;
                  &lt;select asp-for="AgentId"  class ="form-control"  asp-items="ViewBag.Agents"  &gt;&lt;/select&gt;
              &lt;/div&gt;
          &lt;/div&gt;
          &lt;div class="form-group"&gt;
              &lt;div class="col-md-offset-2 col-md-10"&gt;
                  &lt;input type="submit" value="צור חדש" class="btn btn-default" /&gt;
              &lt;/div&gt;
          &lt;/div&gt;
      &lt;/div&gt;
  &lt;/form&gt;
  
  @section Scripts {
      @{await Html.RenderPartialAsync("_ValidationScriptsPartial");}
  }
  </code></pre>