Click here to Skip to main content
14,177,621 members
Click here to Skip to main content
Add your own
alternative version

Tagged as


65 bookmarked
Posted 18 Mar 2010
Licenced CPOL

A Multiple Selection DropDownList (a CheckBoxList Inside a DropDownList)

, 19 Mar 2010
Rate this:
Please Sign up or sign in to vote.
Check and mark more than one option in a DropDownList


This ascx user control, the MultiCheckCombo, allows the user to select more than one option inside a DropDownList. The different items that are being checked are being copied in the box area of the control.

The great thing of this control is that it doesn't close the check panel until you click outside the control. Example: you can check more than one item at once.

In ASP.NET C#, if you need a web control that allows the user to check more than one option in a DropDownList, you can use this user control freely.


Well, first of all, this control was made in Microsoft Visual Studio 2008, with .NET 3.5 (2.0) and was written in C#. To use it, you need to have properly installed the AjaxControlToolkit in your project.

Using the Code

Again: You need to have installed the AjaxControlToolkit in your project.

This control is fairly easy to implement. Simply copy the 3 ascx files into your project.

Then replace the namespace in both ascx and ascx.cs files with [YourProjectName].MultiCheckCombo.

E.g.: Let's suppose your project's name is TestMultiCheck, replace in the ascx file the Control tag with the name of your namespace/project:

<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="MultiCheckCombo.ascx.cs" 

    Inherits="TestMultiCheck.MultiCheckCombo" %>

And in your ascx.cs file, change the namespace to:

namespace TestMultiCheck

Well, then drag and drop the main file (MultiCheckCombo.ascx) to your Page Designer.

You may drag the control inside or outside an UpdatePanel, but you need a ScriptManager at the beginning of the body tag of your aspx page.

<asp:ScriptManager ID="ScriptManager1" runat="server"> </asp:ScriptManager> 

When you drag the control, the following line should be added automatically to the beginning of your aspx page:

<%@ Register src="MultiCheckCombo.ascx" tagname="MultiCheckCombo" tagprefix="uc1" %>

And the code of the control looks like this (it also will be added automatically):

<uc1:MultiCheckCombo ID="MultiCheckCombo1" runat="server" />        

Then, in the code behind (C#), you have to fill the values of the control.

You can fill it with an ArrayList or with an OdbcDataReader.

A: Easy mode: Filling the MultiCheckCombo with an ArrayList:

ArrayList array = new ArrayList();
for (int i=0;i<100;i++) array.Add(i.ToString());

B: Other option is to fill the MultiCheckCombo with an OdbcDataReader:

OdbcConnection con = /* get YOUR connection string*/
OdbcCommand cmd = new OdbcCommand();
cmd.Connection = con;
cmd.CommandText = "select text,id from ...........";
OdbcDataReader dr = cmd.ExecuteReader();
MultiCheckCombo1.AddItems(dr, "text", "id");

And that's it. You can now test it.

Some important properties of this controls are:

MultiCheckCombo1.WidthCheckListBox = 200; //Set the Width of the CheckBoxList inside DDL.
MultiCheckCombo1.Width = 250; //Set the Width of the DropDownList
MultiCheckCombo1.Enabled = true;
MultiCheckCombo1.fontSizeCheckBoxList = FontUnit.Small; 
MultiCheckCombo1.fontSizeTextBox = FontUnit.XSmall;
MultiCheckCombo1.Text; //Get or Set the Text shown in the Combo

Some important methods of this control are:

MultiCheckCombo1.unselectAllItems(); //Uncheck all of the Items of the CheckBox
MultiCheckCombo1.ClearAll(); //Delete all the Items of the CheckBox;

Points of Interest

I hope you can make it work. Cheers! ENJOY IT!

By the way, my e-mail is


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Web Developer
Argentina Argentina
Systems Eng.

You may also be interested in...

Comments and Discussions

GeneralNice one Pin
Member 1338498229-Aug-17 21:06
memberMember 1338498229-Aug-17 21:06 
QuestionQuestion of getting values from this control Pin
Member 1080398913-Mar-15 3:51
memberMember 1080398913-Mar-15 3:51 
QuestionNot Working with IE 9 Pin
bgates19704-Feb-15 5:55
memberbgates19704-Feb-15 5:55 
AnswerVote of execellence Pin
Ritesh bagalkoti12-Nov-14 19:55
memberRitesh bagalkoti12-Nov-14 19:55 
GeneralMy vote of 5 Pin
Member 112144796-Nov-14 23:59
memberMember 112144796-Nov-14 23:59 
GeneralWorks 100% Pin
Member 104302042-Dec-13 3:40
memberMember 104302042-Dec-13 3:40 
GeneralMy vote of 2 Pin
Sharma Richa15-Oct-13 19:49
memberSharma Richa15-Oct-13 19:49 
QuestionRe: My vote of 2 Pin
Ritesh bagalkoti12-Nov-14 19:58
memberRitesh bagalkoti12-Nov-14 19:58 
AnswerRe: My vote of 2 Pin
Ritesh bagalkoti12-Nov-14 19:58
memberRitesh bagalkoti12-Nov-14 19:58 
GeneralMy vote of 2 Pin
Omniasis10-Oct-13 23:38
memberOmniasis10-Oct-13 23:38 
GeneralRe: My vote of 2 Pin
Member 1071740828-May-14 8:05
memberMember 1071740828-May-14 8:05 
AnswerRe: My vote of 2 Pin
Ritesh bagalkoti12-Nov-14 19:58
memberRitesh bagalkoti12-Nov-14 19:58 
GeneralRe: My vote of 2 Pin
Member 1014643211-Jan-15 20:12
memberMember 1014643211-Jan-15 20:12 
Buggetting error Could not load type MultiCheckCombo Pin
Member 100585969-Jul-13 0:41
memberMember 100585969-Jul-13 0:41 
QuestionRead the selected checkbox values Pin
Rockstar_2-Jun-13 19:33
professionalRockstar_2-Jun-13 19:33 
GeneralMy vote of 5 Pin
Rockstar_2-Jun-13 19:23
professionalRockstar_2-Jun-13 19:23 
GeneralMy vote of 5 Pin
cooldiv4u31-May-13 5:10
membercooldiv4u31-May-13 5:10 
GeneralMy vote of 5 Pin
ganeshnarsale2-May-13 0:28
memberganeshnarsale2-May-13 0:28 
BugDoes not work with several controls inside the same page. Pin
Javiere ere24-Jan-13 4:24
memberJaviere ere24-Jan-13 4:24 
QuestionProblem while showing the values after selecting the checkbox in MultiCheckCombo Pin
vaibhavpahade2005078-Jan-13 6:31
membervaibhavpahade2005078-Jan-13 6:31 
BugAfter submit button text box clears the text whereas checkboxes are checked Pin
Soumya Ranjan Maharana29-Nov-12 15:50
memberSoumya Ranjan Maharana29-Nov-12 15:50 
GeneralSelect All option????? Pin
Kalhangarga29-Aug-12 20:25
memberKalhangarga29-Aug-12 20:25 
GeneralRe: Select All option????? Pin
Member 1124551618-Nov-14 20:26
memberMember 1124551618-Nov-14 20:26 
GeneralMy vote of 4 Pin
Chintan Udeshi4-Jul-12 19:40
memberChintan Udeshi4-Jul-12 19:40 
QuestionHow to make checkboxs checked on page load Pin
sheetal20129-Jun-12 9:22
membersheetal20129-Jun-12 9:22 

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.

Permalink | Advertise | Privacy | Cookies | Terms of Use | Mobile
Web01 | 2.8.190526.1 | Last Updated 19 Mar 2010
Article Copyright 2010 by leoivix
Everything else Copyright © CodeProject, 1999-2019
Layout: fixed | fluid