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
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