Jquery UI Multiselect bind items from codebehind
you can use :
$("#<%=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 code:
<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>
Comments
Post a Comment