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

Discussion in 'ASP .Net' started by antonyliu2002, Sep 26, 2005.

  1. 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.
     
    antonyliu2002, Sep 26, 2005
    #1
    1. Advertisements

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 (here). After that, you can post your question and our members will help you out.