[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

David Young

2/15/2004 8:02:00 PM

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


1 Answer

Alvin Bruney

3/2/2004 3:04:00 PM

0

Your post went unanswered. Have you resolved this issue?

--
Regards,
Alvin Bruney [ASP.NET MVP]
Got tidbits? Get it here...
http://tinyurl...
"David Young" <DMTDYoung.nospam@comcast.net> wrote in message
news:OKHk72$8DHA.2604@TK2MSFTNGP10.phx.gbl...
> 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
>
>