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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T18:29:15+00:00 2026-05-28T18:29:15+00:00

I am using VS2005 C#. I am trying to convert my ListBox control to

  • 0

I am using VS2005 C#.

I am trying to convert my ListBox control to the use of DDL.

However in my function of adding a list of user to a specific role, it enables multiple selection in the ListBox.

I would like to change it to the use of DDL, which only allows single selection.

Below is the code:

    string[] newusers = new string[UsersListBox.GetSelectedIndices().Length];

    for (int i = 0; i < newusers.Length; i++)
    {
        newusers[i] = UsersListBox.Items[UsersListBox.GetSelectedIndices()[i]].Value;
    }

The error pointed out that System.Web.UI.WebControls.DropDownList' does not contain a definition for 'GetSelectedIndices.

May I know what can I alter my code for the use of DDL instead of ListBox?

  • 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-28T18:29:17+00:00Added an answer on May 28, 2026 at 6:29 pm

    A DropDownList cannot have multiple items selected, so there is not a GetSelectedIndices() method, as you have noticed. Instead there is a SelectedIndex property.

    string newuser = null;
    if (UserListBox.SelectedIndex > -1)
    {
        newuser = UsersListBox.Items[UsersListBox.SelectedIndex].Value;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using VS2005 C# and im trying to convert a pipe delimited text
I'm using VS2005 and the MS implementation of STL. However, the class type_info in
I have created a C# service using the VS2005 template. It works fine however
I'm trying to compile someone elses C++ program using VS2005 on Windows 2003 (SP2).
I am using VS2005 C#. I am trying to switch my login authentication from
I am using VS2005 C#. I have a list of users and 2 checkboxes.
I am using VS2005 C#, I am trying to import an excel filesheet into
I am using VS2005 and SQL Server 2005. I am trying to execute multiple
I am using VS2005 and SQL Server 2005. I am trying to execute multiple
First of all, I'm using VS2005 and C# 2.0. I'm trying to set a

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.