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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T20:47:07+00:00 2026-05-31T20:47:07+00:00

Hello everyone I’ve been trying to put some objects in an ASP.NET list box

  • 0

Hello everyone I’ve been trying to put some objects in an ASP.NET list box but it’s just not working.

I do have an overridden ToString method so I can’t understand why this statement won’t work.
Here’s the code that I use:

for (int i = 0; i < fitnessClassList.Count(); i++)
{
    lbDisplayItems.Items.Add(fClassList.getFClass(i));
}

And the errors that I get:

Error   2   Argument 1: cannot convert from 
                    'FitClassManage' to 
                    'System.Web.UI.WebControls.ListItem'    

Error   1   The best overloaded method match for 
                    'System.Web.UI.WebControls.ListItemCollection.Add(System.Web.UI.WebControls.ListItem)' 
                    has some invalid arguments
  • 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-31T20:47:08+00:00Added an answer on May 31, 2026 at 8:47 pm

    The ASP.NET ListBox is not like the WinForms ListBox. You cannot add any object to him. Its item collection (ListItemCollection) is limited to ListItem (so you can’t add your business objects relying on ToString() for visualization).

    Use this code:

    ListItem listItem = new ListItem(fitnessClassList.getFitnessClass(i).ToString());
    lbDisplayItems.Items.Add(listItem);
    

    Do not forget that if you’ll use that ListItem you won’t have the object but its display name (the result of ToString()). See the link about the ListItem for more details.

    As alternative you may set the DataSource of the ListView to your fitnessClassList (if it supports that in any way, see this overview on MSDN).

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

Sidebar

Related Questions

Hello everyone I'm trying to improve my Java skills by solving some problems from
Hello everyone iam trying to open a aspx page in a dialog box window
Hello everyone i need some help. I'm trying to make an application for mac
hello everyone I'm trying to write function which can unfold int in the list
Hello everyone I'm trying to make a jquery Menu just like the one in
Hello everyone, I have been banging my head really hard trying to solve this
Hello everyone I am trying to resize an image of 700kb with imagecreatefromjpeg. This
Hello everyone I was just going trough http://static.springsource.org/docs/Spring-MVC-step-by-step/part1.html spring tutorial, and I thought its
Hello everyone I'm trying to work with jboss messaging, does anyone knows the default
Hello everyone i am trying to format the input number range with php number_format

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.