Link to home
Start Free TrialLog in
Avatar of ba272
ba272

asked on

How do I retrieve an object from a listbox?

Hi,

I CAN get the selected item from a listbox without a problem.  But I'm having trouble
when I want to get the first item or the second.  There are so many methods, yet I can't seem to find the one that's right for me.  The content is a string and I'd just like to retrive the string, one by one, for the entir list.

It would be a big help to me if I could solve this ASAP.

Thanks.
ASKER CERTIFIED SOLUTION
Avatar of 123654789987
123654789987

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Daeljan
Daeljan

How about trying this:

ListBox lb = new System.Web.UI.WebControls.ListBox();

// Databind the list here

// Examine the list as below:
foreach (ListItem item in lb.Items)
{
  // Here there is read and write access to the following properties
  item.Text = "Text value";
  item.Value = "Value value";
}