wotney
wotney

Reputation: 1046

Clear CheckBoxList in one line

Does anyone know how to clear a CheckBoxList in one line?

I have a CheckBoxList that holds hundreds of values and I'm just trying to speed up the code.

i.e. without iterating through each checkbox like so:

foreach (ListItem li in cblCategories.Items)
        { li.Selected = false; }

I know this isn't going to make a huge difference to the user experience - I'm just curious if anyone knows a more efficient way of doing this? I was hoping for something like:

cblCategories.Items.Selected = none;

Upvotes: 2

Views: 9099

Answers (1)

Geeky Guy
Geeky Guy

Reputation: 9399

The ClearSelection method, which it inherits from the ListControl class.

Upvotes: 5

Related Questions