mardi 2 février 2016

In Code behind, get all checked values of dynamically created CheckBoxList

In ASP.NET Web Forms, how would I get all checked items of a CheckBoxList that was programmatically created. Assume that I only know the ID of the CheckBoxList.

My guess is something like:

var checklist = Find.Control(id);
foreach (ListItem item in checklist)
{
    if (item.Checked)
    {
        ..Do something
    }
}

But that doesn't seem to grab the CheckBoxList correctly.




Aucun commentaire:

Enregistrer un commentaire