cant get my listbox to display objects
Posted
by
Silvia Stoyanova
on Stack Overflow
See other posts from Stack Overflow
or by Silvia Stoyanova
Published on 2012-03-22T20:49:54Z
Indexed on
2012/03/22
23:29 UTC
Read the original article
Hit count: 324
Hello everyone I've been trying to put some objects in an ASP.NET list box but its just not working.
I do have an overriden ToString method so I cant understand why this statement wont work. Here's the code that I use:
for (int i = 0; i < fitnessClassList.Count(); i++)
{
lbDisplayItems.Items.Add(fitnessClassList.getFitnessClass(i));
}
And the errors that I get:
Error 2 Argument 1: cannot convert from
'FitnessClassManager.FitnessClassOpportunity' 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
© Stack Overflow or respective owner