ASP.NET CheckBoxListControl


Web Server ControlsWeb Server Control

Definition and Usage

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

The selectable items in each CheckBoxList control are defined by ListItem elements!

Tip:This control supports data binding!


Properties

Properties Description .NET
CellPadding The number of pixels between the border and the content of the table cell. 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 repeats horizontally or vertically. 1.0
RepeatLayout The layout of the checkbox group. 1.0
runat Specifies whether the control is a server control. Must be set to "server". 1.0
TextAlign On which side of the checkbox the text appears. 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 the basic functionality of list controls. Controls that inherit from this control include: CheckBoxList, DropDownList, ListBox, and RadioButtonList controls.

For a complete description, please visitListControl 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 visitWeb 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 an .aspx file. Then we create an event handler for the SelectedIndexChanged event. This option list contains six checkboxes. When the user selects one of them, the page automatically posts back to the server and executes the Check subroutine. The subroutine iterates through the control's Items collection and tests the Selected property of each item. The selected items are displayed in a Label control.


Web Server ControlsWeb Server Control Other Extensions