When selecting a value from DropDownList a second time. It doesn't use newly selected value. It uses the old values
<p>I have a div called "ddlFiles". It contains a DropDownList that has a bunch of id's in it. What I am trying to do is get a user to select an id then perform an operation by passing in the selected value.(stored proc needs it) The operation works the first time through. But when I try to select an id again, it uses the old id instead of the new one. So for me to pass in the correct id, I have to get the user to select a new id twice, before it actually takes the second new id.</p>

<p>(NOTE: viewExpensesGrid is the my flexigrid)-not really useful but I thought I'd add it in.</p>

<p>This is my function for getting the selected value from the DropDownList which then passes it to a function:</p>

<pre><code> function getCaseFiles(canMoveExpenses) {
            //create Popup with content from div
            $('#ddlFiles').dialog({
                autoOpen: true,
                height: 'auto',
                width: 'auto',
                modal: true,
                buttons: {
                    "Ok": function () {
                        var dropDownList = document.getElementById("ddlCaseFilesNew");
                        var newCaseDdl = dropDownList.options[dropDownList.selectedIndex].value;
                        //alert("newCaseDdl = " + newCaseDdl);

                        var oldCaseFile = $("#hidCaseFile").val();
                        //alert(oldCaseFile);

                        if (newCaseDdl != -1) {
                            moveCasefile(canMoveExpenses, newCaseDdl, oldCaseFile);
                            $(this).dialog('close');
                            $("#viewExpensesGrid").flexReload();//simply refresh flexigrid
                        }
                        else {
                            showMessage("Error. Please Select a Value From The Lists.");
                        }
                    },
                    Cancel: function () {
                        $(this).dialog('close');
                        $("#viewExpensesGrid").flexReload();
                    }
                }
            });
        }
</code></pre>

<p>And here is my div = "ddlFiles":</p>

<pre><code>&lt;div id="ddlFiles"&gt;
    &lt;label&gt;
        Select new CaseFile:&lt;/label&gt;
    &lt;asp:DropDownList runat="server" ID="ddlCaseFilesNew" DataSourceID="dsCaseFiles"
        DataTextField="Display" DataValueField="FileID" 
        OnPreRender="ddl_PreRender" Width="300px"/&gt;
&lt;/div&gt;
</code></pre>

<p>My stored procedure requires a new CaseId and an old CaseId, the hidCaseFile is a hiddenField. (this already contains the old file ID.</p>
