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 the 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 | Layout of 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.
如需完整描述,请访问 ListControl standard properties.
Web 控件标准属性
AccessKey, Attributes, BackColor, BorderColor, BorderStyle, BorderWidth, CssClass, Enabled, Font, EnableTheming, ForeColor, Height, IsEnabled, SkinID, Style, TabIndex, ToolTip, Width
如需完整描述,请访问 Web 控件标准属性.
控件标准属性
AppRelativeTemplateSourceDirectory, BindingContainer, ClientID, Controls EnableTheming, EnableViewState, ID, NamingContainer, Page, Parent, Site TemplateControl, TemplateSourceDirectory, UniqueID, Visible
如需完整描述,请访问控件标准属性.
实例
- CheckBoxList
- 在此示例中,我们在 .aspx 文件中声明了一个 CheckBoxList 控件。然后我们为 SelectedIndexChanged 事件创建了一个事件处理程序。此可选列表包含六个复选框。当用户选中其中之一时,页面会自动将服务器返回,并执行 Check 子例程。此子例程会遍历控件的 Items 集合,并测试每个项目的 Selected 属性。所选的项目将显示在 Label 控件中。