You can't use this approach, because of the asp.net lifecycle (and the web in general). Basically, each request to the webserver will spawn you asp.net page class, generate the html, send it to the client, and close the instance. Using multithreading technique won't help, because you will change the control tree AFTER the server has sent the answer.
To solve your issue, you should use an <asp:hidden runat='server'>
field.
Then, using some kind of client side script, dynamically populate a drop down list from a web service call.
Something like this using jQuery (from memory):
<select id='ddl' onchange='document.getElementById("<%= hidValue.ClientID %>").value=this.value'>
<option value=''>Loading...</option>
</select>
<asp:Hidden runat='server' id='hidValue' />
$(function(){
$.ajax("... your api endpoit").then(function(result){
var items = result.items; // actual implementation will change
var ddl = $(ddl);
ddl.html(''); // remove the 'loading' option.
foreach(var item in items) {
var option = $("<option>");
option.attr("value",item.value);
option.text(item.text);
ddl.append(option);
}
});
});
The reason not to use an <asp:DropDownList>
is that you can't change its children between postbacks. So we use a pure client one, and sync changes in an hidden control, which can be read on postback.