title: Why is my DropDownList in asp.net not refreshing?
body: <p>I have a simple DropDownList on my asp.net webpage:</p>
  
  <p>It looks like this:</p>
  
  <pre><code>       &lt;asp:UpdatePanel ID="UpdatePanel4" runat="server" UpdateMode="Conditional"&gt;
  
              &lt;ContentTemplate&gt;
                  &lt;asp:DropDownList ID="FriendList" runat="server" 
                       EnableViewState="False" Height="30px" Width="10%"  
                       OnTextChanged="FriendListSwitch" AutoPostBack="True"&gt;
                  &lt;/asp:DropDownList&gt;
              &lt;/ContentTemplate&gt;
  
              &lt;Triggers&gt;
                      &lt;asp:AsyncPostBackTrigger ControlID="btnSend" /&gt;
              &lt;/Triggers&gt;
              &lt;--!The button is a stub, I actually need to load it from the codebehind--&gt;
  
         &lt;/asp:UpdatePanel&gt;
  </code></pre>
  
  <p>Then I have the codebehind like this:</p>
  
  <pre><code>void OnRosterItem(object sender, agsXMPP.protocol.iq.roster.RosterItem item)
  {
      FriendList.Items.Add(new ListItem(String.Format("{0}", item.Jid.User), ""));
      FriendList.DataBind();
  }
  </code></pre>
  
  <p>While debugging I can see that 'FriendList' is being filled, and also that 'btnSend' is being clicked.</p>
  
  <p>Yet my DropDownList is not refilling itself, it just stays empty, why is it not refreshing?</p>
  
  <p>Edit: I'd rather remove the button and replace it with</p>
  
  <pre><code> void OnRosterEnd(object sender)
       {
           UpdatePanel5.Update();
       }
  </code></pre>
  
  <p>But then I keep getting</p>
  
  <pre><code>The Update method can only be called on UpdatePanel with ID 'X' before Render.
  </code></pre>
  
  <p>Solved, the DataBind() only worked inside a Page_Load for me.</p>