Can't get CheckBoxList to work

Discussion in 'ASP .Net Web Controls' started by David Young, Feb 15, 2004.

  1. David Young

    David Young Guest

    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
    David Young, Feb 15, 2004
    #1
    1. Advertising

  2. 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" <> wrote in message
    news:OKHk72$...
    > 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
    >
    >
    Alvin Bruney [MVP], Mar 2, 2004
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Empire City
    Replies:
    1
    Views:
    3,036
    =?Utf-8?B?bWFoc2E=?=
    Jun 15, 2004
  2. JD
    Replies:
    5
    Views:
    11,637
    NetArchitect
    Aug 8, 2007
  3. Patrick.O.Ige
    Replies:
    5
    Views:
    19,100
    Patrick.O.Ige
    Jun 19, 2005
  4. craig dicker
    Replies:
    9
    Views:
    672
    Juan T. Llibre
    Jul 7, 2005
  5. Xeno Campanoli
    Replies:
    1
    Views:
    338
    James Britt
    Jul 1, 2005
Loading...

Share This Page