Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5945851
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T16:44:23+00:00 2026-05-22T16:44:23+00:00

when i execute the code i get 4 checkboxs and i checked/selected all 4

  • 0

when i execute the code i get 4 checkboxs and i checked/selected all 4 checkbox and when i try to debug the code, it does count that i have 4 checkbox but all 4 checkbox is selected=false.

what i am missing in code?

<asp:checkboxlist id="chk" runat="server" ondatabinding="chk_DataBinding"
   ondatabound="chk_DataBound">
</asp:checkboxlist>

List<String> roles = new List<string>();

 for (int i = 0; i < chk.Items.Count; i++)
 {
     if (chk.Items[i].Selected)
    {
        roles.Add(chk.Items[i].Value);
    }
 }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T16:44:24+00:00Added an answer on May 22, 2026 at 4:44 pm

    Your logic is consistent with the basic CheckBoxList given on the ListControl.Items page, and from personal experience, checking the .Selected property of the ListItem should work fine.

    Check to make sure you aren’t re-populating the CheckBoxList before you hit the “if checked” logic – if I had to guess, I’d say there’s a good chance you’re losing the list on every postback. The simple solution is don’t call your databinding logic if it’s a postback.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I get the following error when I try and execute the code down below.
I have some code that at one part will get executed a lot, and
I have some code in method C that will get executed based upon the
I have an event handler that needs to determine a type and execute code
I want to execute some Python code, typed at runtime, so I get the
Is there a way to execute code after each Terminal? So that something like
I have a form with a few buttons which execute code when pressed like
I understand that Javascript doesn't have multiple threads, but I'd like to know if
When I execute this code I get an error saying PHP Fatal error: Call
I have the code below which loops through selected checkboxes and executes and sql

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.