selected items at the top of the listbox

G

Guest

I have a listbox that is databound when my form loads. A user
can then select and option using a drop down box. When the user
selects an option the corresponding items in the listbox gets selected.
How can I show those selected items at the top of my listbox. The
issue is when the user selects an item and it is in the middle of the list,
the user is not able to know an item it is selected or not unless they scroll
through the listbox.
 
C

CsharpGuy

I can get it to select that items, but how do I get them to the top or
scroll to the selected items. That's were I'm stuck.


Munawar Hussain said:
Hi,

what I undesrstand ... is that you have some values in database... from
those values ListBox/dropdown is populated... User select some item and it
is saved in database.
when next time page is loaded and dropdown is populated you want to show
the item on top that user selected last time...

you can use the following scenario
First get the value from database that user selected last time let say
that item is "potato"

then dropdown.items.findByText("potato").selected=true;

this statement will make it selected

in above case you might get error that dropdown cannot have multiple
indexes selected

then you can try this
for(int i=0;i<ddl.Items.Count;i++)

{

ddl.Items.Selected=false;

}

ddl.Items.FindByText("child").Selected=true;



John said:
I have a listbox that is databound when my form loads. A user
can then select and option using a drop down box. When the user
selects an option the corresponding items in the listbox gets selected.
How can I show those selected items at the top of my listbox. The
issue is when the user selects an item and it is in the middle of the
list,
the user is not able to know an item it is selected or not unless they
scroll
through the listbox.
 

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

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,969
Messages
2,570,161
Members
46,710
Latest member
bernietqt

Latest Threads

Top