This is a discussion on "Guide me how to show previously selected item in listbox" within the ASP.NET Forum section. This forum, and the thread "Guide me how to show previously selected item in listbox are both part of the Program Your Website category.
|
|
|
|
|
![]() |
||
Guide me how to show previously selected item in listbox
|
||
| Notices |
![]() |
|
|
LinkBack | Thread Tools |
|
|||
|
Guide me how to show previously selected item in listbox
Dear Friend,
Is anybody guide me how to show previously selected item in a listbox ? I had used listbox control with multiple selection mode. I stored id with comma delimiter in database. e.g. 1. List Item One. 2. List Item Two. 3. List Item Three. 4. List Item Four. 5. List Item Five. Suppose user select item 2, 4 & 5. So I will store it as a 2,4,5 in database. This will work fine. Now in editing I have to shows selection-bar for item 2, item 4 & item 5. So I had typed below source. LstBoxPropHandling.SelectionMode = ListSelectionMode.Multiple; for (j=0; j < PropSplit.Length; j++) { LstBoxPropHandling.SelectedValue = PropSplit[j].ToString(); } But with this statement I got only last item id as a selected item with selectionbar. In our example 2,4,5 only item whose id is 5 got as a selected item. Is anybody guide me how to make item 2, item 4, item 5 as a selected item ? Thanking You, |
|
|
|
|||
|
Re: Guide me how to show previously selected item in listbox
This is an unfortunate shortcoming of the standard listbox control; SelectedIndex and SelectedValue don't work for multi-select situations.
What you need to do in your loop is this: for (j=0; j < PropSplit.Length; j++) { LstBoxPropHandling.Items.FindByValue(PropSplit[j].ToString()).Selected = true; } |
![]() |
| Tags |
| guide, show, previously, selected, item, listbox |
| Thread Tools | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How to view selected field only? | awiezzz | Classic ASP | 1 | May 13th, 2007 16:12 |
| display on the page an item selected with a form drop down | antonyx | JavaScript Forum | 1 | Aug 22nd, 2006 15:05 |
| Date/Time format & multiple selection with listbox problem | frmsasp | ASP.NET Forum | 0 | Oct 12th, 2005 10:29 |
| Case insensitive listbox | Ozeona | Flash & Multimedia Forum | 1 | Sep 15th, 2005 17:20 |
| Return to previously viewed screen | Imara96 | Flash & Multimedia Forum | 5 | Apr 23rd, 2005 22:18 |