ASP finds dropdown with 0 elements but the elements are there
<p>I'm using ASP to look for the selected value in a dropdown box. The dropdown box choices are generated at load time. Here is the JavaScript for that:</p>

<pre><code>function CreateDepartmentDropdown(data) {
    var dropdown = document.getElementById("department_dropdown");
    for (var i = 0; i &lt; data.length; i++) {
        var array = data[i].split(',');
        var option = document.createElement("option");
        option.value = array[0];
        option.innerHTML = array[1];
        dropdown.add(option);
    }
}
</code></pre>

<p>And it looks like this:</p>

<p><a href="https://i.stack.imgur.com/63sPj.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/63sPj.png" alt="enter image description here"></a></p>

<p>Looks fine to me. Then I checked the HTML out too just to be sure:</p>

<p><a href="https://i.stack.imgur.com/lTalC.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/lTalC.png" alt="enter image description here"></a></p>

<p>That looks great too. Now here is where the issue comes up. When I press submit this delegate fires in C# (still only testing while making this):</p>

<pre><code>void Activity_Submit_Click(object sender, EventArgs e)
{
    int fye = Int32.Parse(fye_dropdown.Value);
    String activity_name = activity_name_field.Value;
    String activity_responsible = responsible_field.Value;
    int department = Int32.Parse(department_dropdown.Value);
    String activity_start = datepicker_start.Value;
    String activity_end = datepicker_end.Value;
}
</code></pre>

<p>And when I debug this it stops at department saying that it's malformed. Looking at <code>department_dropdown.Value</code> in the immediate window turns up an empty string and the dropdown itself has 0 children.</p>

<p>Why would this return an empty response when the list is clearly there? How would I go about fixing this?</p>