Get selected values in ListBox with multiple selectionmode property

Discussion in 'ASP .Net Web Controls' started by Matthew Louden, Nov 13, 2003.

  1. I created a listbox with multiple selectionmode property, but I have trouble
    to get a list of selected values.

    The following only gets the first selected value, not others.

    TextBox2.Text = ListBox1.SelectedValue

    Please help!!
    Thanks
     
    Matthew Louden, Nov 13, 2003
    #1
    1. Advertisements

  2. Matthew Louden

    Hero Ngan Guest

    I think you can use a For-Loop to loop the listbox, then check the item is
    selected or not.

    Roughly code:

    ' loop the ListBox items
    For iLoop = 0 To ListBox1.Items.Count - 1
    ' item selected
    If ListBox1.Items(iLoop).Selected Then
    TextBox2.Text = TextBox2.Text & ListBox1.Items(iLoop).Value & ";"
    End If
    Next

    Hope can help you!

    Rdgs,
    Hero Ngan


    "Matthew Louden" <> ¼¶¼g©ó¶l¥ó·s»D
    :...
    > I created a listbox with multiple selectionmode property, but I have

    trouble
    > to get a list of selected values.
    >
    > The following only gets the first selected value, not others.
    >
    > TextBox2.Text = ListBox1.SelectedValue
    >
    > Please help!!
    > Thanks
    >
    >
     
    Hero Ngan, Nov 13, 2003
    #2
    1. Advertisements

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Matthew Louden
    Replies:
    1
    Views:
    21,497
    Hero Ngan
    Nov 13, 2003
  2. Matthew Sajdera

    Listbox Control Not Returning Selected Values

    Matthew Sajdera, Apr 12, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    579
    Matthew Sajdera
    Apr 12, 2004
  3. =?Utf-8?B?VmlwaW4gS2VkaWE=?=

    .Selected property for listbox does not work

    =?Utf-8?B?VmlwaW4gS2VkaWE=?=, Feb 11, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    503
    =?Utf-8?B?VmlwaW4gS2VkaWE=?=
    Feb 11, 2005
  4. K B
    Replies:
    2
    Views:
    831
  5. Fabio Visin
    Replies:
    3
    Views:
    1,694
    Steven Cheng
    Feb 21, 2008
  6. Seb
    Replies:
    0
    Views:
    683
  7. Vipin Kedia

    .Selected property for listbox does not work

    Vipin Kedia, Feb 11, 2005, in forum: ASP .Net Building Controls
    Replies:
    0
    Views:
    182
    Vipin Kedia
    Feb 11, 2005
  8. Vipin Kedia

    .Selected property for listbox does not work

    Vipin Kedia, Feb 11, 2005, in forum: ASP .Net Web Controls
    Replies:
    1
    Views:
    230
    Sean McKaharay
    Feb 14, 2005
Loading...