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

  • SEARCH
  • Home
  • 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 6758927
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T13:51:57+00:00 2026-05-26T13:51:57+00:00

How to get selected index in a check box list in asp.net. Should I

  • 0

How to get selected index in a check box list in asp.net. Should I loop through to find whether the list box is selected or can i get to know without doing that. I want to do this

if(Checkboxlist selected)
{do this}
else
{do this}

how to find if the check box list is selected or not in asp.net

int roleselected = ckl_EditRole.Items.SelectedIndex;
  • 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-26T13:51:57+00:00Added an answer on May 26, 2026 at 1:51 pm

    For CheckBoxList, SelectedIndex will give you just the first selected index in the CheckBoxList. If it’s not -1, then something was selected. This may be enough for what you’re looking for.

    if( ckl_EditRole.SelectedIndex != -1 )
    {
    // Do Something
    }
    

    But, since the CheckBoxList can have multiple selections, you probably want to loop through the Items and look for the selected ones.

    foreach( ListItem li in ckl_EditRole.Items )
    {
        if( li.Selected )
        {
            // Do Something
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How to get Selected row index in DBGrid ? so Im using ADOQuery ->
I want to get a code, that I want the selected tab index in
How do I get the selected value from a dropdown list using JavaScript? <form>
How can I get the selected text (not the selected value) from a drop-down
HTML Javascript question to get the selected value of a input-select I can use
Greetings, how to get the selectedindex of check box from checkboxlist control using jquery?
I have an ASP.NET MVC Website that has a dropdown list that is being
I'm trying to get the selected value from a drop down list via jQuery.
How to get the selected index (from a number of jcheckbox added to the
I know this is a topic where you can find tons of answers for...

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.