Guide me how to show previously selected item in listbox

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.



Go Back   Webforumz.com > Main Forums > Program Your Website > ASP.NET Forum

Notices


Reply
 
LinkBack Thread Tools
  #1 (permalink)  
Old Oct 12th, 2005, 05:30
New Member
Join Date: Sep 2005
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
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,
Reply With Quote

  #2 (permalink)  
Old Jan 26th, 2006, 14:37
New Member
Join Date: Jan 2006
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
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;
}
Reply With Quote
Reply

Tags
guide, show, previously, selected, item, listbox

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

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


All times are GMT. The time now is 15:59.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43