How to create session objects for all selected items of a listbox?

A

antonyliu2002

I am not new to programming, but I am new to VB .NET.

I have a multiselect listbox like this:

Please select your favorite fruit:

Apple
Banana
Coconut
Date

Note that multiple selection is enabled.

If the user makes a selection of Banana and Date, what is the easiest
way to create session objects for both Banana and Date? Do I have to
use a for loop like the following?

For each itmFruits in lstbxFruits.Items
If itmFruits.Selected Then
Session(itmFruits.Text) = itmFruits.Text
End If
Next

Also, what is the easiest way to retrieve session objects of a
multiselect listbox when the session collection also has session
objects created for other controls?

I want the user to be able to make selections from this fruit selection
page, go to any other page of the same site, come back and still have
the items selected. That's why I wanna know of any easier way to
implement this, multiselect listbox in particular.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,743
Messages
2,569,478
Members
44,898
Latest member
BlairH7607

Latest Threads

Top