Web Server Controls->ASP.NET CheckBoxList Control
2007-03-27 09:05
477 查看
Definition and Usage
The CheckBoxList control is used to create a multi-selection check box group.Each selectable item in a CheckBoxList control is defined by a ListItem element!
Tip: This control supports data binding!
Properties
Property | Description |
---|---|
AutoPostBack | A Boolean value that specifies whether the form should be posted immediately after one of the items changes select status or not. Default is false |
CellPadding | The space, in pixels, between the cell walls and the check box group |
DataSource | The data source to use |
DataTextField | A field in the data source to be displayed in the check box group |
DataValueField | A field in the data source that specifies the value of each selectable item in the check box group |
id | A unique id for the control |
OnSelectedIndexChanged | The name of the function to be executed when one of the items changes select status |
RepeatColumns | The number of columns to use when displaying the check box group. Default is "1" |
RepeatDirection | Specifies whether the check box group should be repeated horizontally or vertically. Legal values are "Horizontal" and "Vertical". Default is Vertical |
RepeatLayout | The layout of the check box group. Can be "Table" or "Flow". Default is Table |
runat | Specifies that the control is a server control. Must be set to "server" |
TextAlign | On which side of the check box the text should appear (right or left) |
Examples
CheckBoxListASPX Source:
<script runat="server"> Sub Check(sender As Object, e As EventArgs) dim i mess.Text="<p>Selected Item(s):</p>" for i=0 to check1.Items.Count-1 if check1.Items(i).Selected then mess.Text+=check1.Items(i).Text + "<br />" end if next End Sub </script> <html> <body> <form runat="server"> <asp:CheckBoxList id="check1" AutoPostBack="True" TextAlign="Right" OnSelectedIndexChanged="Check" runat="server"> <asp:ListItem>Item 1</asp:ListItem> <asp:ListItem>Item 2</asp:ListItem> <asp:ListItem>Item 3</asp:ListItem> <asp:ListItem>Item 4</asp:ListItem> <asp:ListItem>Item 5</asp:ListItem> <asp:ListItem>Item 6</asp:ListItem> </asp:CheckBoxList> <br /> <asp:label id="mess" runat="server"/> </form> </body> </html> |
Output Result:
|
Item 1 |
相关文章推荐
- Web Server Controls->ASP.NET CheckBox Control
- Web Server Controls->ASP.NET Calendar Control
- Web Server Controls->ASP.NET Label Control
- Web Server Controls->ASP.NET RadioButton Control
- Web Server Controls->ASP.NET LinkButton Control
- Web Server Controls->ASP.NET RadioButtonList Control
- Janus Web/ASP.NET Server Controls v3(3.5.0.35) for VS2005
- Web Server Controls->ASP.NET ListBox Control
- Web Server Controls->ASP.NET TableCell Control
- Web Server Controls->ASP.NET DropDownList Control
- Web Server Controls->ASP.NET Literal Control
- Web Server Controls->ASP.NET TableRow Control
- ASP.NET Web server controls
- Web Server Controls->ASP.NET AdRotator Control
- Web Server Controls->ASP.NET HyperLink Control
- Web Server Controls->ASP.NET XML Control
- Web Server Controls->ASP.NET Panel Control
- Web Server Controls->ASP.NET Table Control
- Web Server Controls->ASP.NET Button Control
- Web Server Controls->ASP.NET Image Control