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. Advertising

  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. Advertising

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,263
    Hero Ngan
    Nov 13, 2003
  2. K B
    Replies:
    2
    Views:
    680
  3. Fabio Visin
    Replies:
    3
    Views:
    1,288
    Steven Cheng
    Feb 21, 2008
  4. Seb
    Replies:
    0
    Views:
    581
  5. Calendar SelectionMode

    , May 30, 2006, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    138
Loading...

Share This Page