On "Page_Load" I fill a DropDownList with my data source:
lstBoxGrupAcessID.DataTextField = "Description";
lstBoxGrupAcessID.DataValueField = "ID";
lstBoxGrupAcessID.DataSource = new BLLCompany().SelectLstGroupBox(objCompany.CompanyID);
lstBoxGrupAcessID.DataBind();
After this, I need to set the lstBoxGrupAcess with some pre-selected itens ( specific for each company ) ( just for sample, I will select all the itens on the lstBoxGrupAcessID )
foreach (ListItem itm in lstBoxGrupAcessID.Items)
itm.Selected = true;
When I execute the page, I got this erro:
Cannot have multiple items selected in a DropDownList.
The inicialization of SumoSelect in my code is:
<script>
$(document).ready(function () {
var list = $('#<%=lstBoxGrupAcessID.CompanyID%>');
list.SumoSelect({
selectAll: false
});
});
Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndRequestHandler);
function EndRequestHandler(sender, args) {
var list = $('#<%=lstBoxGrupAcessID.CompanyID%>');
list.SumoSelect({
selectAll: false
});
}
</script>
The declaration of my DropDownList is:
<asp:DropDownList ID="lstBoxGrupAcessID" runat="server" multiple="multiple" CssClass="form-control"></asp:DropDownList>
You must use asp:ListBox for select multiple items, not Dropdown