Cannot bind data to an ASP.NET DropDownList in a UpdatePanel
<p><strong>In the process of writing this, I ran the code again only to see it work. I am still interested in an explanation of what would cause this. I'm tempted to blame browser caching but that doesn't quite explain it because many changes to the codebehind were reflected in the rendered HTML. I highly doubt it was a careless mistake as I had a coworker double-check it while it was still misbehaving</strong> <em>I am still posting this in case someone else has a similar issue</em></p>

<p>I am attempting to populate an ASP DropDownList after a different DropDown is changed but the data won't stick. Here is the code:</p>

<pre><code>ddlAccount.Items.Clear()
ddlAccount.Items.Add(New ListItem("-- Select --", ""))

Dim accounts As List(Of DSQL.ProtocolAccount) = FormDataBinder.GetAccountList()

ddlaccount.datasource = accounts
ddlaccount.databind()
</code></pre>

<p>I can see that the accounts variable has 3 records when I debug, but I don't see them in the generated html. Since Databind isn't working I attempted to add the values manually, and that is when I got surprising results.</p>

<pre><code>ddlAccount.Items.Clear()
ddlAccount.Items.Add(New ListItem("-- Select --", ""))

Dim accounts As List(Of DSQL.ProtocolAccount) = FormDataBinder.GetAccountList()

Dim i = 0

'Loop through all accounts, adding an arbitrarily valued ListItem for each one.'
For Each account As DSQL.ProtocolAccount In accounts
    i = i + 1
    ddlAccount.Items.Add(New ListItem("Account "&amp; i , i))
    'ddlAccount.Items.Add(New ListItem(account.AccountDescription, account.AccountID))'
Next

' Add another ListItem for the sake of it '
i = i + 1
ddlAccount.Items.Add(New ListItem("Thing "&amp; i , i))

' Add 5 more from a loop for the sake of it '
For i = 100 to 105
    ddlAccount.Items.Add(New ListItem("Test "&amp; i, i))
Next
</code></pre>

<p>After running that code I would expect the dropdown to look like this:</p>

<blockquote>
  <p>-- Select --</p>
  
  <p>Account 1</p>
  
  <p>Account 2</p>
  
  <p>Account 3</p>
  
  <p>Thing 4</p>
  
  <p>Test 100</p>
  
  <p>Test 101</p>
  
  <p>Test 102</p>
  
  <p>Test 103</p>
  
  <p>Test 104</p>
  
  <p>Test 105</p>
</blockquote>

<p>In the debugger, I can see this line of code being run 3 times: <strong>ddlAccount.Items.Add(New ListItem("Thing "&amp; i , i))</strong></p>

<p>Unfortunately, this is what I get back.</p>

<blockquote>
  <p>-- Select --</p>
  
  <p>Thing 1</p>
  
  <p>Test 100</p>
  
  <p>Test 101</p>
  
  <p>Test 102</p>
  
  <p>Test 103</p>
  
  <p>Test 104</p>
  
  <p>Test 105</p>
</blockquote>
