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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T18:09:51+00:00 2026-06-04T18:09:51+00:00

Basically I need to populate a listBox’s .Text value with a string and its

  • 0

Basically I need to populate a listBox’s .Text value with a string and its .Value value with an int.
By doing this:

lbUsers.DataSource = new UserManagerBO().GetGlobalUserList();
lbUsers.DataBind();

This assigns a string to both .Value and .Text.

Now I know GetGlobalUserList() returns a string[] which is why I’m getting the behaviour above, so how to go about returning the int values along with the string ones? Maybe go 2D array? And then how to bind those results to the 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-06-04T18:09:53+00:00Added an answer on June 4, 2026 at 6:09 pm

    Option 1
    Let that method return string[] and for value pick SelectedIndex.

    Option 2
    Create a custom class as Damith answers.

    Option 3
    A Dictionary<int, string> will suffice.

    Dictionary Keys for ListBox Value and Dictionary Values for ListBox Text.

    Say this is the dictionary returned by your method

    //Adding key value pair to the dictionary
    Dictionary<int, string> dStudent = new Dictionary<int, string>();
    dStudent.Add(0, "Eena");
    dStudent.Add(1, "Meena");
    dStudent.Add(2, "Deeka");
    dStudent.Add(3, "Tom");
    dStudent.Add(4, "Dick");
    dStudent.Add(5, "Harry");
    dStudent.Add(6, "Yamla");
    dStudent.Add(7, "Pagla");
    dStudent.Add(8, "Dewana");
    dStudent.Add(9, "Guru");
    dStudent.Add(10, "Sholay");
    

    Step 2:

    Now it’s time to bind a Dictionary pair with your listbox. The following code binds to listbox.

    //binding to the list
    lst.DataTextField = "Value";
    lst.DataValueField = "Key";
    lst.DataSource = dStudent;
    lst.DataBind();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Basically I need to scrape some text that has nested tags. Something like this:
basically need to change the value that - admin_url() returns any idea?
I basically need to check if there is an easier way to do this
What I'm Doing: I basically need to create a website secured by a login
I've been looking around the internet hoping that this is possible, I basically need
Basically I need to be able to do this: var obj = {foo:bar}, arr
Basically I need to reset Identity Increment for all tables to its original. Here
i need some clarification on how to populate select(s) with data from mysql. Basically
Basically need to generate custom(some different then yes no) messeges(alert) in JS , how
basically i need some algorithm that fits into the following problem: i have 5

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.