The difference is that you are referring to 2 different listbox controls.
In a Windows Forms project, you are using the System.Windows.Forms.Listbox
control, which has an Items collection that exposes an Add method. This Add
method only allows Objects to be passed to it and a Folder is an Object, so
your syntax: lstFolders.Items.Add(folder); works just fine.
In an ASP.NET Web Project, you are using the
System.Web.UI.WebConrols.Listbox control, which also exposes an Items
collection that has an Add method as well. But, this Add method only
accepts ListItem objects or Strings. Since your Folder is not a ListItem
object, you must treat it as a string, hence ToString is needed.
The bottom line is that in an ASP.NET Web application, you will be using
different controls than in a Windows Forms application and although you will
see controls that look the same in both kinds of projects, they are not the
same controls and may have differences between them.
-Scott
"Garth Wells" <no****@nowhere.com> wrote in message
news:%2***************@TK2MSFTNGP10.phx.gbl...
I'm working with an SDK from a commercial software
vendor and am using a sample Windows Application
written in C# to learn the SDK (they do not have an
ASP.Net example). I need to create an ASP.Net Web
Application and have noticed that I'm having to ToString
the object references. For example, the following works
in the samle code:
// Get the list from the server
foreach (LoanFolder folder in Globals.Session.Loans.Folders)
lstFolders.Items.Add(folder);
but it must be converted to this:
// Get the list from the server
foreach (LoanFolder folder in Globals.Session.Loans.Folders)
lstFolders.Items.Add(folder.ToString());
to work in ASP.Net. So this call from the SDK:
LoanIdentityList loans = parentFolder.GetContents();
turns into:
LoanIdentityList loans =
Globals.Session.Loans.Folders[parentFolder].GetContents();
What's the fundamental difference between the two types of
applications that require the changes?
Thanks