CheckBoxList component of ASP. NET page

Source: Internet
Author: User

The component selected by CheckBox is a common component in a program. When this component is used in programming, it is generally not used only for one, but often in the form of multiple such components. To use multiple CheckBox components on the ASP. NET page, in addition to adding multiple CheckBox components to the page, you can also use the CheckBoxList component. The CheckBoxList component is composed of a group of CheckBox components. In this component, the CheckBox appears as an entry, and each CheckBox in the CheckBoxList component has an index number, in this way, it is easier to process in the program.

At this point, you may ask, isn't this an option? Now that we have the CheckBox component, what should we do with the CheckBoxList component? This is because in the Process of program design, it is easier and clearer to process the CheckBoxList component than to process the CheckBox component. Example:

Assume that there is a CheckBoxList component and ten CheckBox components, and the CheckBoxList component is composed of these ten CheckBox components.

1. How to Create a CheckBoxList component:
<Asp: CheckBoxList runat = "server" id = C1>
<Asp: ListItem Value = 1> first check box </asp: ListItem>
<Asp: ListItem Value = 2> second check box </asp: ListItem>
<Asp: ListItem Value = 3> third check box </asp: ListItem>
.....
Note: You can add several check boxes here.
</Asp: CheckBoxList>

Add the preceding statement to the ASP. NET page to generate a CheckBoxList component named "C1.

2. Attributes frequently used in the CheckBoxList component:

1. TextAlign attribute: The value is Left or Right. If the value of TextAlign is Left, the text of the check box in the CheckBoxList component is on the Left of the check box. Similarly, if the value of TextAlign is Right, the text of the check box is on the Right of the check box.

2. Selected attribute: boolean type, used to determine whether the check box in the component is Selected.

3. RepeatColumns attributes: There are several check boxes in the CheckBoxList component. This attribute mainly sets how many rows are used to display these check boxes.

4. RepeatDirection attribute: the value of this attribute can be Vertical or Horizontal. After the RepeatColumns attribute is set, it is set to arrange the check boxes in the component. The details are as follows:
Assume that the CheckBoxList component has four check boxes and the RepeatColumns attribute value is 2.
1). If RepeatDirection = Vertical, check the box on the page as follows:
Check box 01 check box 03
Check box 02 check box 04
2) If RepeatDirection = Horizontal, check the box display on the page as follows:
Check box 01 check box 02
Check box 03 check box 04

5. Count attribute: return the number of check boxes in the CheckBoxList component.

Iii. methods frequently used in the CheckBoxList component:

1. Add a check box to the component. The syntax is as follows:
CHKList. Items. Add (new ListItem (<text>, <value> ))

2. Access the check box in the component. The syntax is as follows:
CHKList. Items [<index>]

3. Delete the check box in the component. The syntax is as follows:
CHKList. Items. Remove (<index>)

Iv. Summary:

In fact, the CheckBoxList component is also a server component. This article describes some of the main attributes and methods of the CheckBoxList component. NET page, in fact, for another important component, CheckBox, they have many similarities, after understanding the usage of the CheckBoxList component, you can also master the usage of the CheckBox component.

  1. Brief Introduction to ASP applications
  2. IScriptControl of ASP. NET
  3. ASP. NET Authentication Service
  4. Overview ASP. NET Security
  5. ASP. NET ISAPI

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.