While your validation check may work there are a few redundancies there. the bool
isitchecked is not really necessary. You also do not check whether the Item is a CheckBox. I would try something like this
public bool AreCheckBoxesSelected()
{
for (int i = 0; i < CheckBoxList1.Items.Count; i++)
{
if (CheckBoxList1.Items[i] is CheckBox)
{
if (!CheckBoxList1.Items[i].Selected)
{
return false;
}
}
}
return true;
}
protected void Button1_Click(object sender, EventArgs e)
{
if (AreCheckBoxesSelected())
{
SaveResult();
MessageBox.Show("Success ..... Yaaaaaaay");
}
else
{
MessageBox.Show("No Joy. Ensure all Check Boxes are CHECKED please.");
}
}
This assumes that you have a Method SaveResult which would save the
result?
Hope this helps