Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Controls > Can't get CheckBoxList to work

Reply
Thread Tools

Can't get CheckBoxList to work

 
 
David Young
Guest
Posts: n/a
 
      02-15-2004
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


 
Reply With Quote
 
 
 
 
Alvin Bruney [MVP]
Guest
Posts: n/a
 
      03-02-2004
Your post went unanswered. Have you resolved this issue?

--
Regards,
Alvin Bruney [ASP.NET MVP]
Got tidbits? Get it here...
http://tinyurl.com/3he3b
"David Young" <(E-Mail Removed)> wrote in message
news:OKHk72$(E-Mail Removed)...
> 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
>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
how to get the values of checkboxlist in javascript? Mark ASP .Net 2 01-05-2008 10:02 AM
Checkboxlist inside Repeater - doesn't fire click event for Checkboxlist JD ASP .Net 5 08-08-2007 11:28 AM
How to get Selected item in a Databinded CheckBoxList when CheckBoxlist is in a DataList? Patrick.O.Ige ASP .Net 5 06-19-2005 06:11 AM
CheckBoxList In A DataGrid - Can I get what's selected without using the Edit Empire City ASP .Net 1 06-15-2004 04:45 PM
DataValue doesn't get bound to CheckBoxList Sam ASP .Net 0 01-28-2004 10:09 PM



Advertisments