ASP.NET CheckBoxList Control

Definition and Usage

The CheckBoxList control is used to create a multi-select checkbox group.

Each option in a CheckBoxList control is defined by a ListItem element!

Tip:The control supports data binding!

Properties

Properties Description .NET
CellPadding The number of pixels between the border of the table cell and its content. 1.0
CellSpacing The number of pixels between table cells. 1.0
RepeatColumns The number of columns used when displaying the checkbox group. 1.0
RepeatDirection Specifies whether the checkbox group is horizontally or vertically repeated. 1.0
RepeatLayout The layout of the checkbox group. 1.0
runat Specifies that the control is a server control. It must be set to "server". 1.0
TextAlign The text appears on the side of the checkbox. 1.0

ListControl Standard Properties

AppendDataBoundItems, AutoPostBack, CausesValidation, DataTextField,
DataTextFormatString, DataValueField, Items, runat, SelectedIndex, SelectedItem,
SelectedValue, TagKey, Text, ValidationGroup, OnSelectedIndexChanged

The ListControl control includes all basic functions of list controls. Controls inheriting from this control include: CheckBoxList, DropDownList, ListBox, and RadioButtonList controls.

For a complete description, please visit ListControl Standard Properties.

Web Control Standard Properties

AccessKey, Attributes, BackColor, BorderColor, BorderStyle, BorderWidth, 
CssClass, Enabled, Font, EnableTheming, ForeColor, Height, IsEnabled, 
SkinID, Style, TabIndex, ToolTip, Width

For a complete description, please visit Web Control Standard Properties.

Control Standard Properties

AppRelativeTemplateSourceDirectory, BindingContainer, ClientID, Controls, 
EnableTheming, EnableViewState, ID, NamingContainer, Page, Parent, Site, 
TemplateControl, TemplateSourceDirectory, UniqueID, Visible

For a complete description, please visitControl Standard Properties.

Example

CheckBoxList
In this example, we declare a CheckBoxList control in the .aspx file. Then we create an event handler for the SelectedIndexChanged event. This optional list contains six checkboxes. When the user selects one, the page will automatically send it back to the server and execute the Check subroutine. This subroutine will iterate through the control's Items collection and test each item's Selected property. The selected items will be displayed in the Label control.