CheckBox and CheckBoxList are server controls in .Net.
Check boxes are an appropriate choice in situations where a radio button won't work. When deciding which control to use, when multiple selections are possible, we can use check boxes.
Check boxes allow the user to select a true or false condition.
We all have seen I accept Terms and Conditions with a check box when installing software.
DropDownList: A DropDownList is also a combo box. It can contain multiple data members, but unlike a normal list box the users can choose only one value from this control. Enables users to select from a single-selection drop-down list. The drop-down list can contain any number of items.
In my working project I used CheckBoxList Control for selecting skill set.
There is a dropdown list which is having options like MS technologies, Java Technologies, Databases, Operating systems, Web Designing tools etc.
Based on selected item we are showing CheckBoxList. If he selects MS Technologies we are showing MS related technologies using CheckBox List.
These are steps to know the process of given Example:
<!--[if !supportLists]-->1. <!--[endif]-->Created DropDownList. And added list items.
<!--[if !supportLists]-->2. <!--[endif]-->Depends on the selection of list item CheckboxList are shown.
<!--[if !supportLists]-->3. <!--[endif]-->Select the CheckBoxList Items.
<!--[if !supportLists]-->4. <!--[endif]-->When Click on the button 'submit', message will be shown.
DropDownList code:
<tr>
<td class="style1">
<asp:DropDownList ID="ddlist" runat="server" onselectedindexchanged= "ddltechs" AutoPostBack="true">
<asp:ListItem Text="=SELECT=" Value="SELECT"></asp:ListItem>
<asp:ListItem Text="MS Technologies" Value="MS Technologies"></asp:ListItem>
<asp:ListItem Text="Java Technologies" Value="Java Technologies"> </asp:ListItem>
<asp:ListItem Text="Databases" Value="Databases"></asp:ListItem>
</asp:DropDownList>
</td>
</tr>
CheckBoxList controls code:
/******For MS Technologies*****/
<tr id="trMS" runat="server" visible="false">
<td class="style1">
<asp:CheckBoxList ID="MSTechTechnologies" runat="server">
<asp:ListItem Text="ASP.Net" Value="ASP.Net"></asp:ListItem>
<asp:ListItem Text="ASP.Net" Value="ASP.Net"></asp:ListItem>
<asp:ListItem Text="C#.Net" Value="C#.Net"></asp:ListItem>
<asp:ListItem Text="VB.Net" Value="VB.Net"></asp:ListItem>
<asp:ListItem Text="J#.Net" Value="J#.Net"></asp:ListItem>
<asp:ListItem Text="WCF" Value="WCF"></asp:ListItem>
<asp:ListItem Text="WPF" Value="WPF"></asp:ListItem>
<asp:ListItem Text="Silverlight" Value="Silverlight"></asp:ListItem>
</asp:CheckBoxList>
</td>
</tr>
/******For Java Technologies*******/
<tr id="trJava" runat="server" visible="false">
<td class="style1">
<asp:CheckBoxList ID="JavaTech" runat="server">
<asp:ListItem Text="Core Java" Value="Core Java"></asp:ListItem>
<asp:ListItem Text="J2SE" Value="J2SE"></asp:ListItem>
<asp:ListItem Text="J2EE" Value="J2EE"></asp:ListItem>
<asp:ListItem Text="JSP" Value="JSP"></asp:ListItem>
<asp:ListItem Text="SERVLET" Value="SERVLET"></asp:ListItem>
<asp:ListItem Text="EJB" Value="EJB"></asp:ListItem>
<asp:ListItem Text="JNDI" Value="JNDI"></asp:ListItem>
</asp:CheckBoxList>
</td>
</tr>
/*******For DataBases*******/
<tr id="trDB" runat="server" visible="false">
<td class="style1">
<asp:CheckBoxList ID="DataBases" runat="server">
<asp:ListItem Text="SQL Server" Value="SQL Server"></asp:ListItem>
<asp:ListItem Text="Oracle" Value="Oracle"></asp:ListItem>
<asp:ListItem Text="MySql" Value="MySql"></asp:ListItem>
<asp:ListItem Text="DB2" Value="DB2"></asp:ListItem>
<asp:ListItem Text="PostGreSQL" Value="PostGreSQL"></asp:ListItem>
<asp:ListItem Text="MS Access" Value="MS Access"></asp:ListItem>
<asp:ListItem Text="Informix" Value="Informix"></asp:ListItem>
</asp:CheckBoxList>
</td>
</tr>
/******** When DropDownList Select Index Changed*******/
string list="";
string chkvalue = Convert.ToString(hdnparameter.Value);
if (chkvalue == "SELECT")
{
lblmsg.Text = "You should select Something::: ";
}
if (chkvalue == "MS Technologies")
{
for (int index = 0; index < MSTechTechnologies.Items.Count; index++)
{
if (MSTechTechnologies.Items[index].Selected)
{
list = list + MSTechTechnologies.Items[index].Text + ",";
}
}
}
else if (chkvalue == "Java Technologies")
{
for (int index = 0; index < JavaTech.Items.Count; index++)
{
if (JavaTech.Items[index].Selected)
{
list = list + JavaTech.Items[index].Text + ",";
}
}
}
else
{
for (int index = 0; index < DataBases.Items.Count; index++)
{
if (DataBases.Items[index].Selected)
{
list = list + DataBases.Items[index].Text + ",";
}
}
}
lblmsg.Text = "You are having these skills:" + list;
lblmsg.Visible = true;
/******** When Button Click happens********/
value = (ddlist.SelectedItem.Value).Trim();
hdnparameter.Value = value;
if (value == "SELECT")
{
lblmsg.Visible = true;
lblmsg.Text = "Please select";
trMS.Visible = false;
trJava.Visible = false;
trDB.Visible = false;
}
else if (value == "MS Technologies")
{
trMS.Visible = true;
trJava.Visible = false;
trDB.Visible = false;
lblmsg.Text = "";
}
else if (value == "Java Technologies")
{
trJava.Visible = true;
trMS.Visible = false;
trDB.Visible = false;
lblmsg.Text = "";
}
else
{
trDB.Visible = true;
trMS.Visible = false;
trJava.Visible = false;
lblmsg.Text = "";
}
The Result is like this:

Note: Source Code is available at Downloadload links.
I hope you like this article...

hawraa Al_ShammariPosted Apr 17, 2017, 6:14 PM
How download this code ??
K P Singh ChundawatPosted May 28, 2013, 1:43 AM
getting error in hdnparameter.value.....
munna banglaPosted Mar 11, 2011, 9:05 AM
sir i need d result like user name: scott courses offerd: cb c#.net ../ cb asp.net ../ cb vb.net cb sql server if scott selected c#.net and asp.net the result will be like " scott selected c#.net and asp.net" if no selection done result will be like " scott selected no check boxes" i need the prom here cb means CHECK BOX ../ means selected
Amar JeetPosted Jan 25, 2011, 11:36 PM
the frst link is broken that contain the name "CheckBoxList and DropDownList.zip" nd the second one is working that contain the name "CheckBox_ CheckBoxList_ DropDownList.zip " so user's can use the second 1 nd @Jitendra u sud hv to give the proper working link to dwnload the file fr other user's nd the article is much helpful fr me thnx fr upload.......Regards Amar
SuhailPosted Jan 13, 2011, 12:27 AM
Hi, Please send working link for this source code. Thanks in Advance Regards suhail
Prashant NairPosted Jan 7, 2011, 5:35 AM
Download Link Not Working ! The page cannot be found Error
Sharique ImamPosted Nov 18, 2010, 6:49 AM
What is hdn in the above code?