title: Adding Items to ListBox Asynchronously
body: <p>I am working on adding items to a ListBox, <code>uxSearchList</code>. However, even though <strong>the code behind works as expected</strong>, the changes do not reflect within the <code>uxSearchList</code> ListBox after clicking <code>Search</code>.</p>
  
  <p>I do the following: </p>
  
  <ul>
  <li>Enter search criteria (<code>uxEsnCheck/Text</code>, <code>uxLocationList/Text</code>)</li>
  <li>Click on <code>Search</code></li>
  <li>(in progress) Populate search results into <code>uxSearchList</code></li>
  </ul>
  
  <p>How do I populate the <code>uxSearchList</code> ListBox through what I currently have? My code is below.</p>
  
  <hr>
  
  <p><strong>.ASPX.CS</strong></p>
  
  <pre><code>    protected void uxSearchParams_Click(object sender, EventArgs e)
      {
          uxSearchList.Items.Clear();
  
          var selectedSerial = uxEsnText.Text;
          var selectedLocation = uxLocationList.Text;
  
          if (!uxEsnText.Enabled)
          {
              selectedSerial = string.Empty;
          }
          if (!uxLocationList.Enabled)
          {
              selectedLocation = string.Empty;
          }
  
          if (Page.IsValid)
          {
              var selectedParams = _presenter.OnSelectionParams(selectedSerial, selectedLocation);
  
              foreach (var param in selectedParams)
              {
                  uxSearchList.Items.Add(param.SerialNumber);
              }
          }
      }
  </code></pre>
  
  <p><strong>.ASPX</strong></p>
  
  <pre><code>        &lt;asp:UpdatePanel ID="uxParamsPanel" runat="server" UpdateMode="Conditional"&gt;
              &lt;ContentTemplate&gt;
                  &lt;asp:CheckBox ID="uxEsnCheck" runat="server" CssClass="form-label" Text="Engine Serial Number" OnCheckedChanged="uxEsnCheck_CheckedChanged" AutoPostBack="true" /&gt;
                  &lt;asp:TextBox ID="uxEsnText" runat="server" Enabled="False"/&gt;
  
                  &lt;asp:CheckBox ID="uxLocationCheck" runat="server" CssClass="form-label" Text="Location" OnCheckedChanged="uxLocationCheck_CheckedChanged" AutoPostBack="true" /&gt;
                  &lt;asp:DropDownList ID="uxLocationList" runat="server" Enabled="False"/&gt;
  
                  &lt;asp:Button ID="uxSearchParams" runat="server" onclick="uxSearchParams_Click" CssClass="form-label" Text="Search" /&gt;
              &lt;/ContentTemplate&gt;
              &lt;Triggers&gt;
                  &lt;asp:AsyncPostBackTrigger ControlID="uxSearchParams" EventName="Click" /&gt;
  
                  &lt;asp:AsyncPostBackTrigger ControlID="uxEsnCheck" EventName="CheckedChanged" /&gt;
                  &lt;asp:AsyncPostBackTrigger ControlID="uxLocationCheck" EventName="CheckedChanged" /&gt;
              &lt;/Triggers&gt;
          &lt;/asp:UpdatePanel&gt;
  
          &lt;asp:UpdatePanel ID="uxSelectionPanel" runat="server" UpdateMode="Conditional"&gt;
              &lt;ContentTemplate&gt;
                  &lt;asp:Label ID="uxSearchDisplay" runat="server" CssClass="form-label" Text="Search Results" /&gt;
                  &lt;asp:ListBox ID="uxSearchList" runat="server" Width="250px" /&gt;
  
                  &lt;asp:Label ID="uxMemberDisplay" runat="server" CssClass="form-label" Text="Engine Group Members" /&gt;
                  &lt;asp:ListBox ID="uxMemberList" runat="server" Width="250px" /&gt;
  
                  &lt;asp:Button ID="uxAdd" runat="server" onclick="uxAdd_Click" Text="&gt;" /&gt;
                  &lt;asp:Button ID="uxRemove" runat="server" onclick="uxRemove_Click" Text="&lt;" /&gt;
              &lt;/ContentTemplate&gt;
              &lt;Triggers&gt;
                  &lt;asp:AsyncPostBackTrigger ControlID="uxAdd" EventName="Click" /&gt;
                  &lt;asp:AsyncPostBackTrigger ControlID="uxRemove" EventName="Click" /&gt;
              &lt;/Triggers&gt;
          &lt;/asp:UpdatePanel&gt;
  </code></pre>