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 6174537
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T23:46:14+00:00 2026-05-23T23:46:14+00:00

so, I have a checkListBox that i’m trying to get the value member of

  • 0

so, I have a checkListBox that i’m trying to get the value member of the checked boxes. Currently, I can get the selectedValue of one item. If multiple items are checked, i get the same selectedValue for each.

The box is populated like so…

SqlConnection cn = new SqlConnection(Properties.Settings.Default.cs);
SqlDataAdapter da = new SqlDataAdapter();
da.SelectCommand = new SqlCommand("usp_getCustomers, cn);
DataSet ds = new DataSet();
da.Fill(ds, "usp_getCustomers");
chkListCustomer.DataSource = ds;
chkListCustomer.DisplayMember = "usp_getCustomers.name";
chkListCustomer.ValueMember = "usp_getCustomers.id";
chkListCustomer.SelectedIndex = -1;

On a button click, this is what i’m doing to TRY and get the selected values. It gives me the right ID for one item, but if multiple items are checked, it gives the same ID back for all.

foreach (int indexChecked in chkListCustomer.CheckedIndices)
{
    MessageBox.Show("Index#: " + indexChecked.ToString() + ", is checked. Checked state is:" + chkListCustomer.SelectedValue.ToString()  + ".");   
}

example output is:

"Index#: 1, is checked. Checked state is:984"  
"Index#: 2, is checked. Checked state is:984"  
"Index#: 3, is checked. Checked state is:984" 

thanks for the help!

  • 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-23T23:46:15+00:00Added an answer on May 23, 2026 at 11:46 pm

    modified a piece of code found on SO on this post from Ahmad Mageed. This gives me each

        foreach (object itemChecked in chkListPatients.CheckedItems) 
        {
            DataRow row = (itemChecked as DataRowView).Row;
            string id = row[0].ToString();
            MessageBox.Show(id);
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Have one Doubt In MVC Architecture we can able to pass data from Controller
I am currently building a dynamic url tab system that user can say what
I have a CheckListBox in c# and I am trying to trigger an event
i want to have a group of check boxes like CheckListBox with different back
I am trying to get either the strings checked or the integers from a
I want to have a number of objects that can be added to a
I have a CheckedListBox where I want an event after an item is checked
Have deployed numerous report parts which reference the same view however one of them
I have a checkedListBox (c#) and would like to have some of the boxes
I have an ASPX C# page with a CheckListBox . Using the following code

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.