Iterate Through ListBox Items

Posted: September 27, 2011 in ASP.Net

To iterate through all items of a ListBox control, you can try the following:

for (int i = 0; i <= ListBox1.Items.Count - 1; i++) 
{
  int itemIndex = i;
  string itemText = ListBox1.Items(i).Text;
  string itemValue = ListBox1.Items(i).Value;
}
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s