Private Void Page_Load (Object Sender, System.Eventargs E) {CheckBoxList CBL = New CheckBoxList (); CBL.ID = "CBL"; CBL.Items.Add (New ListItem ("1", "1")); CBL. Items.Add (New ListItem ("2")); CBL.Items.Add (New ListItem ("3", "3")); this.page.controls [1] .controls.add (CBL ); Cbl.selectedIndexchanged = new system.eventhandler (this.checkboxlist1_selected); CBL.Autopostback = true;}
private void CheckBoxList1_SelectedIndexChanged (object sender, System.EventArgs e) {Response.Write ( "value of the selected item:
"); foreach (ListItem li in ((CheckBoxList) sender) .Items) {if (li.Selected) {Response.write (li.value "
);}}}