How to add DropDownLists to a popup populated from a stored procedure
<p>I'm trying to add 2 drop down lists to a popup. but I am having trouble.</p>

<p>I have a function called "showMessage" that creates a popup.</p>

<p>so: showMessage("hello"); will create a popup with the words "hello".  Now my question is how could I add 2 dropdownlists to it. I've tried creating a div with 2 dropdownlists then doing
showMessage(document.getElemenyBiId(ddl)); But I know that's not right.</p>

<p>here is my "showMessage" function:</p>

<pre><code>function showMessage(msg, title, onOk) {
if (title === undefined)
    title = "";

if (onOk === undefined)
    onOk = function () {
        $(this).dialog('close');
    }

$('&lt;div&gt;').dialog({
    title: title,
    height: 'auto',
    width: '250',
    open: function () {
        $(this).html(msg);
    },
    buttons: {
        Ok: onOk
    },
    close: function () {
        $(this).remove();
    }
});
</code></pre>

<p>}</p>

<p>and here is my dropdownList div:</p>

<pre><code>&lt;div id="newExpenseTypeDialog" style="display:none;"&gt;
        &lt;label&gt;Select new CaseFile:&lt;/label&gt;
        &lt;asp:DropDownList runat="server" ID="ddlCaseFiles" DataSourceID="dsMyCaseFiles" DataTextField="Display" DataValueField="FileID" OnPreRender="ddl_PreRender" Width="524px" /&gt;
&lt;/div&gt;
</code></pre>

<p>javascript function I have to where I am trying to get a popup to load 2 dropdownlists and then getting a user to select an id from both then have it pass the 2 values to the function to do what I want it to do.</p>

<pre><code>function moveCasefile(isMovePossible) {
        //var newCaseFileID;
        //var oldCaseFileID;
         //this area I am trying to get the popup to happen and get the input from the user via dropdownLists.
        if (newCaseFileID || oldCaseFileID) {
            //alert(ans);

            var selectedExpensesList = getSelectedExpenseIDs();
            if (selectedExpensesList.length &gt; 0) {
                $.ajax({
                    type: "POST",
                    //url: "/Tasks/ViewTasks.aspx/deleteTasksAndLinkedItems",
                    url: '&lt;%=ResolveUrl("~/Expenses/ViewExpenses.aspx/moveNewCaseFile")%&gt;',
                    data: "{'MoveCaseFile' : '" + isMovePossible + "','ExpId': ['" + selectedExpensesList.join('\',\'') + "'],'newCaseFileID': '" +
                    newCaseFileID + "', 'oldCaseFileID': '" + oldCaseFileID + "'}",
                    //dataaaaaa`
</code></pre>

<p>My div with the DropDownLists:</p>

<pre><code>&lt;div id="newExpenseTypeDialog" style="display:none;"&gt;
        &lt;label&gt;Select new CaseFile:&lt;/label&gt;
        &lt;asp:DropDownList runat="server" ID="ddlCaseFiles" DataSourceID="dsMyCaseFiles" DataTextField="Display" DataValueField="FileID" OnPreRender="ddl_PreRender" Width="524px" /&gt;
        &lt;asp:DropDownList runat="server" ID="ddlCaseFiles2" DataSourceID="dsMyCaseFiles" DataTextField="Display" DataValueField="FileID" OnPreRender="ddl_PreRender" Width="524px" /&gt;
&lt;/div&gt;
</code></pre>

<p>My DropdownLists data source:</p>

<pre><code>&lt;asp:SqlDataSource ID="dsMyCaseFiles" runat="server" ConnectionString="&lt;%$ ConnectionStrings:OSCIDConnectionString %&gt;" ProviderName="System.Data.SqlClient" SelectCommand="p_CaseFiles_ListActiveCaseFilesAssignedTo" SelectCommandType="StoredProcedure"&gt;
    &lt;SelectParameters&gt;
        &lt;asp:SessionParameter Name="InvestigatorID" SessionField="InvestigatorID" /&gt;
        &lt;asp:SessionParameter Name="AssignedTo" SessionField="InvestigatorID" /&gt;
    &lt;/SelectParameters&gt;
&lt;/asp:SqlDataSource&gt;
</code></pre>

<p>And my Codebehind for "pre_render":</p>

<pre><code> protected void ddl_PreRender(object sender, EventArgs e)
{
    DropDownList ddl = (DropDownList)sender;
    try
    {
        if (ddl.Items[0].Value != "-1")
            ddl.Items.Insert(0, new ListItem("--Select--", "-1"));
    }
    catch
    {
        ddl.Items.Insert(0, new ListItem("--Select--", "-1"));
    }
}
</code></pre>
