ASP.NET CheckBoxList control
Definition and usage
CheckBoxList control is used to create a multi-select checkbox group.
Each option in a CheckBoxList control is defined by a ListItem element!
Tip:This control supports data binding!
Properties
Properties | Description | .NET |
---|---|---|
CellPadding | Pixels between the border of the table cell and the content. | 1.0 |
CellSpacing | Pixels between table cells. | 1.0 |
RepeatColumns | The number of columns used when displaying the checkbox group. | 1.0 |
RepeatDirection | Specify whether the checkbox group is horizontally or vertically repeated. | 1.0 |
RepeatLayout | Layout of checkbox groups | 1.0 |
runat | Specify that this control is a server control. It must be set to "server". | 1.0 |
TextAlign | 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
ListControl controls include all basic functions of list controls. Controls that inherit 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 控件中。