Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/jquery-ui/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jquery ui Jquery UI从codebehind中选择多个绑定项_Jquery Ui_Postback_Code Behind_Multi Select_Setvalue - Fatal编程技术网

Jquery ui Jquery UI从codebehind中选择多个绑定项

Jquery ui Jquery UI从codebehind中选择多个绑定项,jquery-ui,postback,code-behind,multi-select,setvalue,Jquery Ui,Postback,Code Behind,Multi Select,Setvalue,我正在使用jqueryuimultiselect插件将dropdownlist与Multiselect项一起使用,我需要帮助将保存在数据库中的选定项bing回Multiselect下拉列表 例如: 页面加载时的Javascript代码: $("#<%=ddlCountry.ClientID%>").multiselect({ checkAllText: "All", uncheckAllText: "Clear", no

我正在使用jqueryuimultiselect插件将dropdownlist与Multiselect项一起使用,我需要帮助将保存在数据库中的选定项bing回Multiselect下拉列表

例如:

页面加载时的Javascript代码:

$("#<%=ddlCountry.ClientID%>").multiselect({
            checkAllText: "All",
            uncheckAllText: "Clear",
        noneSelectedText: "Select a country",
        selectedText: "# item(s) selected",
        close: function (event, ui) {
            var values = $("#<%=ddlCountry.ClientID%>").val();
            var array_of_checked_values = $("#<%=ddlCountry.ClientID%>").multiselect("getChecked").map(function () {
                return this.value;
            }).get();
            document.getElementById("<%=txtHidDataCountry.ClientID%>").value = array_of_checked_values;
        }
    });
DropDownList ASPX代码:

<div id="dvPais" style="display:none">
   <asp:DropDownList ID="ddlCountry" runat="server">
    </asp:DropDownList>
    <input type="hidden" id="txtHidDataCountry" runat="server" />
</div>
<asp:DropDownList ID="ddlTeste" runat="server" multiple>
    <asp:ListItem Value="1">Valor 1</asp:ListItem>
    <asp:ListItem Value="2">Valor 2</asp:ListItem>
    <asp:ListItem Value="3">Valor 3</asp:ListItem>
    <asp:ListItem Value="4">Valor 4</asp:ListItem>
    <asp:ListItem Value="5">Valor 5</asp:ListItem>
</asp:DropDownList>

在选择3个国家后完成提交时,我的it值为1,2,3。当我再次加载页面时,我需要从下拉列表中选择项目1、2、3。我如何才能做到这一点?

仅给出我找到的解决方案:

$("#<%=ddlTeste.ClientID%>").multiselect({
        checkAllText: "All",
        uncheckAllText: "Clear",
    noneSelectedText: "Select a country",
    selectedText: "# item(s) selected",
    close: function (event, ui) {
        var values = $("#<%=ddlTeste.ClientID%>").val();
        var array_of_checked_values = $("#<%=ddlTeste.ClientID%>").multiselect("getChecked").map(function () {
            return this.value;
        }).get();
        document.getElementById("<%=txtHidDataTeste.ClientID%>").value = array_of_checked_values;
    }
});
var s = $("#<%=ddlTeste.ClientID%>").multiselect();
s.val(['1', '2','5']);
$("#<%=ddlTeste.ClientID%>").multiselect('refresh');
ASPX代码:

<div id="dvPais" style="display:none">
   <asp:DropDownList ID="ddlCountry" runat="server">
    </asp:DropDownList>
    <input type="hidden" id="txtHidDataCountry" runat="server" />
</div>
<asp:DropDownList ID="ddlTeste" runat="server" multiple>
    <asp:ListItem Value="1">Valor 1</asp:ListItem>
    <asp:ListItem Value="2">Valor 2</asp:ListItem>
    <asp:ListItem Value="3">Valor 3</asp:ListItem>
    <asp:ListItem Value="4">Valor 4</asp:ListItem>
    <asp:ListItem Value="5">Valor 5</asp:ListItem>
</asp:DropDownList>

享受:

例如:使用$select.multiselectwidget.find:checkbox[value='abc'].eachfunction{this.click;},我选择一个特定的值。如果我想选择两个值,我该怎么做?