Checkboxlist component of ASP. NET page

Source: Internet
Author: User

The checkbox selection component isProgramCommon components. 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.

In fact, for another important component, checkbox, they have many similarities. They master the usage of the checkboxlist component and generally master the usage of the checkbox component.

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.