Click here to Skip to main content
11,934,783 members (50,857 online)
Click here to Skip to main content
Add your own
alternative version


97 bookmarked

Multi select Dropdown list in ASP.NET

, 19 Mar 2007
Rate this:
Please Sign up or sign in to vote.
Multiselect dropdown list control allows the user to select multiple items from the list and displays the selected items in comma separated format.


The Dropdown list in ASP.NET is used to select a single item from the list. The Listbox control is used to select multiple items, but it takes up more space on the page. An ASP.NET page which contain many of these controls may make it difficult to find the proper space and alignment for each control.

To overcome this, I am introducing a Multi Select Dropdown list box control. It is a user control and can be used directly on pages very easily. It allows the user to select multiple items from the list and the selected items will be displayed in comma separated format in the text area, and it can also persist the selected items.

How to use this Control

The user control MultiSelectDropDown can be placed on any Web page.

Drag and drop the MultiSelectDropDown control on the web page where you want to use the multi select feature.

Populate the dropdown with appropriate values. In my sample it has been populated as follows:

private void Page_Load(object sender, System.EventArgs e)
   if (!Page.IsPostBack )
    MultiSelectDropDown1.List.Items.Add(new System.Web.UI.WebControls.ListItem("Apple","1")) ;
    MultiSelectDropDown1.List.Items.Add(new System.Web.UI.WebControls.ListItem("Grapes","2")) ;
    MultiSelectDropDown1.List.Items.Add(new System.Web.UI.WebControls.ListItem("Orange","3")) ;
    MultiSelectDropDown1.List.Items.Add(new System.Web.UI.WebControls.ListItem("Strawberry","4")) ;
    MultiSelectDropDown1.List.Items.Add(new System.Web.UI.WebControls.ListItem("Water Melon","5")) ;

System.Collections.ArrayList selTexts = MultiSelectDropDown1.SelectedTexts;

SelectedTexts property returns an Arraylist of the selected items in the list, SelectedValues property

The following are the main public properties provided by this control:

SelectedTexts Arraylist of selected texts in the list
SelectedValues Arraylist of values corresponding to the selected items in the list
SelectedText Comma separated string of selected texts
SelectedItems Arraylist of values and texts corresponding to the selected items in the list
ListWidth Set/Get the width of the control
List List of items


The following screenshot shows how to select multiple items from the list:

The width of the control can be changed by the ListWidth property of the control.

MultiSelectDropDown1.ListWidth = Convert.ToDouble(txtWidth.Text);

The following image shows that the control width has changed to 150 from 250 when you enter 150 in the Dropdown width field and click on Set DD width button.

The dropdown also shows the tooltip of the selected texts in comma separated format. It helps the user to find out what the selected items are, without clicking on the dropdown if the width of the dropdown is not large enough to display all the selected texts.

The following image shows the tooltip of the text:

The selected items in the list will be added to the Selected Fruits Listbox when you click on Display selected fruits button.

The code is given below:

System.Collections.ArrayList selItems = MultiSelectDropDown1.SelectedTexts;
ListBox1.DataSource = selItems;

The following code shows how to set the selected items of the control:

ArrayList selectedItems = new ArrayList();
// Select the items from the list
foreach (System.Web.UI.WebControls.ListItem selItem in ListBox1.Items )
   System.Web.UI.WebControls.ListItem li = ListBox1.Items.FindByText(selItem.Text ) ;
MultiSelectDropDown1.SelectedItems =selectedItems;

It sets the SelectedItems property of the control with the ArrayList of items.


This is a very useful and simple control and can be used on any web page irrespective of the .NET version.


This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


About the Author

Deepthi Viswanathan Nair
United States United States
No Biography provided

You may also be interested in...

Comments and Discussions

QuestionNot Working with IE 9 Pin
bgates19704-Feb-15 6:51
memberbgates19704-Feb-15 6:51 
Question[My vote of 1] Multiselect dropdown Pin
ritika luthra7-Sep-14 23:47
memberritika luthra7-Sep-14 23:47 
QuestionControl use doubts Pin
Member 102186741-Sep-14 7:49
memberMember 102186741-Sep-14 7:49 
QuestionMultiSelect Dropdown List(Custom Control) Pin
Member 1065311111-Mar-14 3:34
memberMember 1065311111-Mar-14 3:34 
QuestionMulti select Dropdown list in ASP.NET Pin
Sabyasachi Misra6-Nov-13 1:58
professionalSabyasachi Misra6-Nov-13 1:58 
Questionbrowser compatebale Pin
Member 1002984726-Sep-13 20:28
memberMember 1002984726-Sep-13 20:28 
AnswerRe: browser compatebale Pin
Sabyasachi Misra6-Nov-13 3:11
professionalSabyasachi Misra6-Nov-13 3:11 
QuestionHow to Highlight items in Multi dropdown on Mouseover Pin
chanikya0327-Jun-13 22:15
memberchanikya0327-Jun-13 22:15 
QuestionCreate Dropdown with checkbox in mvc4 Pin
sonihemant23-Apr-13 21:30
membersonihemant23-Apr-13 21:30 
QuestionCan we implement the same using JQuery? Pin
sweatha.murthy5-Jun-12 21:52
membersweatha.murthy5-Jun-12 21:52 
AnswerRe: Can we implement the same using JQuery? Pin
vinodkumarnie29-Mar-13 20:36
membervinodkumarnie29-Mar-13 20:36 
QuestionMultiSelectDropDown Pin
Shivani Sinha8-May-12 22:24
memberShivani Sinha8-May-12 22:24 
naveen511015-Sep-11 11:33
membernaveen511015-Sep-11 11:33 
NeerajGuru23-Mar-12 11:27
memberNeerajGuru23-Mar-12 11:27 
now, when you have a masterpage, the control names are different. it will be of the type
ctl00_ContentPlaceHolder1_MultiSelectDropDown1_DDList instead of just DDList.Masterpage changes your contol names. You can find out your control name my going into the view source of that page.

Now, to fix this control to work for masterpages, just go into MultiSelectDropDown.ascx

In all the function calls, add ctlId = "ctl00_ContentPlaceHolder1_MultiSelectDropDown1_";

Then it started working for me. Remember , ctl00_ContentPlaceHolder1_MultiSelectDropDown1_ is the way my masterpage names my controls. The name of the control depends on the name of the ContentPlaceHolder in your masterpage. SO please go to the view source in IE or any browser and find out the way your masterpage names your controls.

Questionhow to get the content or title value of respective page source url [modified] using Pin
manivannnanpon16-Aug-10 1:01
membermanivannnanpon16-Aug-10 1:01 
GeneralMulti-Select Drop Down List in ASP.NET Pin
Richard Xiong11-Aug-10 15:07
memberRichard Xiong11-Aug-10 15:07 
GeneralMy vote of 4 Pin
prashant0556.s.more26-Jul-10 1:42
memberprashant0556.s.more26-Jul-10 1:42 
GeneralDear Nair Madam Pin
tharuraju21-Jul-10 8:15
membertharuraju21-Jul-10 8:15 
GeneralIm Not able to select items. Pin
Member 422664018-Apr-10 21:16
memberMember 422664018-Apr-10 21:16 
QuestionCan you Guide me, I am new Pin
Trupti Mehta6-Aug-09 1:29
memberTrupti Mehta6-Aug-09 1:29 
AnswerRe: Can you Guide me, I am new Pin
vinodkumarnie29-Mar-13 20:39
membervinodkumarnie29-Mar-13 20:39 
QuestionCould you please guide me to bind a dataset to this user control? Pin
Harikaran S20-Jul-09 4:27
memberHarikaran S20-Jul-09 4:27 
GeneralMulti-Select with Master page Pin
Member 33793814-Mar-09 11:22
memberMember 33793814-Mar-09 11:22 
GeneralRe: Multi-Select with Master page Pin
Donna Belville28-Apr-09 9:44
memberDonna Belville28-Apr-09 9:44 
GeneralMultiple controls on same page error Pin
maxitaxi28-Oct-07 21:51
membermaxitaxi28-Oct-07 21:51 
GeneralRe: Multiple controls on same page error Pin
Deepthi Viswanathan Nair29-Nov-07 7:40
memberDeepthi Viswanathan Nair29-Nov-07 7:40 
QuestionHow to link to Javascript. Pin
mx200425-Sep-07 17:52
membermx200425-Sep-07 17:52 
AnswerRe: How to link to Javascript. Pin
mx200425-Sep-07 18:21
membermx200425-Sep-07 18:21 
GeneralUsing Checkboxes Pin
pgenocide10-Sep-07 10:19
memberpgenocide10-Sep-07 10:19 
GeneralRe: Using Checkboxes Pin
Deepthi Viswanathan Nair29-Nov-07 7:52
memberDeepthi Viswanathan Nair29-Nov-07 7:52 
GeneralRe: Using Checkboxes Pin
sohan shekhawat27-Feb-08 1:47
membersohan shekhawat27-Feb-08 1:47 
QuestionWhere's the MultiSelectDropdown in ASP.NET 2.0? Pin
jonefer27-Apr-07 17:00
memberjonefer27-Apr-07 17:00 
QuestionBrowser compatible? Pin
Prasad J24-Apr-07 18:48
memberPrasad J24-Apr-07 18:48 
AnswerRe: Browser compatible? Pin
Donna Belville9-Feb-09 8:31
memberDonna Belville9-Feb-09 8:31 
QuestionCan you please explain Pin
Ennis Ray Lynch, Jr.19-Mar-07 12:35
memberEnnis Ray Lynch, Jr.19-Mar-07 12:35 
AnswerRe: Can you please explain Pin
Deepthi Viswanathan Nair19-Mar-07 13:09
memberDeepthi Viswanathan Nair19-Mar-07 13:09 
GeneralRe: Can you please explain Pin
Jaiprakash M Bankolli15-Apr-07 22:42
memberJaiprakash M Bankolli15-Apr-07 22:42 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.151126.1 | Last Updated 19 Mar 2007
Article Copyright 2007 by Deepthi Viswanathan Nair
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid