CheckBoxList

You can use two types of ASP.NET controls to add check boxes to a Web Forms page: individual CheckBox controls or a CheckBoxList control. Both controls provide a way for users to input Boolean data: true or false, yes or no. For a comparison of the two types of controls, see CheckBox.

To add a CheckBoxList control to a page

  • Drag the CheckBoxList control from the Toolbox panel to your page.

When you use a CheckBoxList control, you add a single control to the page. Adding items to the control is a separate process that depends on whether you will display a static list in the control or display a list that is generated dynamically from a data source.

To define static items for the CheckBoxList control

  1. In Design view, right-click the CheckBoxList control, and then click ShowCommon Control Tasks****.

  2. On the Common CheckBoxList Tasks menu, click Edit Items.

  3. In the ListItem Collection Editor dialog box, click Add to add an item.

  4. In the ListItem properties area, set the Text and Value properties.

  5. Repeat steps 3 and 4 until you have added all the items you want.

To bind the CheckBoxList control to a data source

  1. In Design view, right-click the CheckBoxList control, and then click ShowCommon Control Tasks****.

  2. On the Common CheckBoxList Tasks menu, click Choose Data Source.

  3. In the Data Source Configuration Wizard, choose a source for the CheckBoxList control in the Select a data source dropdown. In the Select a data fieldto displayin the CheckBoxList dropdown, select the field for the text that the user will see. In the Select a data field for the value of the CheckBoxList dropdown, select the field for the data that can be programmatically accessed when the user chooses an item in the list.

For more information about managing CheckBox and CheckBoxList controls, see CheckBox and CheckBoxList Web Server Controls (Visual Studio) Cc294907.xtlink_newWindow(en-us,Expression.40).png in the MSDN library.

See also

Concepts

CheckBox

Send feedback about this topic to Microsoft. © 2011 Microsoft Corporation. All rights reserved.