Topic: RadioButtonList Or Checkboxlist
C# CHECKBOXLIST or RadioButtonList
To get or set the values from a CheckBoxList or RadioButtonList control, use a For Each loop to check each control in the list.
The controls contained in a CheckBoxlist control are not Checkbox controls, as you might expect. Instead, the CheckBoxList
and RadioButtonList controls contain ListControls. To determine the setting of a ListControl control, use the "Selected"
property, as show in the following code:
private void Button1_Click(object sender, System.EventArgs e)
{
foreach (ListItem lstitem in CheckBoxList1.items)
{
if (lstItem.Selected)
Response.Write(lstItem.Text + " is selected<br/>");
}
}