7.15. Adding a CheckBoxList Control

This section adds a CheckBoxList control. The motivation is to allow the user to vote for multiple items by clicking on them. The page is pictured in Figure 7.6.

Figure 7.6. A CheckBoxList Control Example

The initialization of the CheckBoxList control is similar to that of the previous two list controls, except that we specify that the check boxes should be displayed in columns of two items per line:

 private void Page_Load(object sender, System.EventArgs e) { if ( ! IsPostBack ) { string [] selections = { "Twelfth Night", "Romeo and Juliet", "Hamlet", "MacBeth", "All\'s Well That Ends Well", "Henry IV, Part ...

Get C# Primer: A Practical Approach now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.