Rocky
Rocky

Reputation: 4524

DropdownList with Multi select option?

I have a DropDownList as following

<asp:DropDownList ID="ddlRoles" runat="server" AutoPostBack="True" Width="150px">
<asp:ListItem Value="9" Text=""></asp:ListItem>
<asp:ListItem Value="0">None</asp:ListItem>
<asp:ListItem Value="1">Ranu</asp:ListItem>
<asp:ListItem Value="2">Mohit</asp:ListItem>
<asp:ListItem Value="3">Kabeer</asp:ListItem>
<asp:ListItem Value="4">Jems</asp:ListItem>
<asp:ListItem Value="5">Jony</asp:ListItem>
<asp:ListItem Value="6">Vikky</asp:ListItem>
<asp:ListItem Value="7">Satish</asp:ListItem>
<asp:ListItem Value="8">Rony</asp:ListItem>
</asp:DropDownList>

I want to select Multiple name at once suppose I want to select Ranu Mohit or Ranu Kabeer Vikky, How its possible?

Upvotes: 0

Views: 26171

Answers (1)

Kyle Pollard
Kyle Pollard

Reputation: 2313

asp:DropDownList does not support multiple selects:

VerifyMultiSelect(): Always throws an HttpException exception because multiple selection is not supported for the DropDownList control.

You can use asp:ListBox with SelectionMode="Multiple" instead:

<asp:ListBox SelectionMode="Multiple" ID="lbRoles" runat="server" AutoPostBack="True" Width="150px">
    <asp:ListItem Value="9" Text=""></asp:ListItem>
    <asp:ListItem Value="0">None</asp:ListItem>
    <asp:ListItem Value="1">Ranu</asp:ListItem>
    <asp:ListItem Value="2">Mohit</asp:ListItem>
    <asp:ListItem Value="3">Kabeer</asp:ListItem>
    <asp:ListItem Value="4">Jems</asp:ListItem>
    <asp:ListItem Value="5">Jony</asp:ListItem>
    <asp:ListItem Value="6">Vikky</asp:ListItem>
    <asp:ListItem Value="7">Satish</asp:ListItem>
    <asp:ListItem Value="8">Rony</asp:ListItem>
</asp:ListBox>

Upvotes: 1

Related Questions