Can't get CheckBoxList to work

D

David Young

I have a CheckBoxList with 3 checkbox items in it. I'm trying to
programatically check one or more of the items.

ListItem myCheckBoxItem = myCheckBoxList.Items[0]; //select the first item
myCheckBoxItem.Selected = true;

Now, if I'm not mistaken, this should make the first checkbox in the
checkboxlist to be checked when the control is rendered, right? We'll it's
not checked with the page is rendered and I don't get any errors
(compiletime or runtime).

The controls Enabled property is set to "true",

I've even tried the following with no success:
CheckBox myCheckBox = (CheckBox)myCheckBoxList.Controls[0];
myCheckBox.Checked = true;

Again, I get no errors but the first checkbox does not get checked. And
yes, I've tried using myCheckBoxList.Items.FindByValue and FindByText, and
I've tried setting the other two as well. All with no success.

Any guesses?

David
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,904
Latest member
HealthyVisionsCBDPrice

Latest Threads

Top