select listbox

M

Mike

I have an edit page that contains a listbox. I want to select the items in it that were passed from the previous page, but have them at the top of the list box. is there a way to do that/

so for example:
on my main page I have in my grid

BMW, Mercedes, Lexus

when I click edit, I want
BMW, Mercedes, Lexus selected in my listbox (which I have) but at the top so I don't have to scroll looking for them.
Even though they may not be at the top when the list is bound, if they're selected I want them first.

Is there a way to do this?
 
S

sloan

Where are you getting the source data for the models?


If you need them in a certain order, then you can do something like this:


ddl.DataSource = something.GetData();
ddl.DataBind();

ddl.Items.Insert ( 0 , new ListItem ("BMW" , 101) ) ;
ddl.Items.Insert ( 0 , new ListItem ("Mercedes", 102) ) ;
ddl.Items.Insert ( 0 , new ListItem ("Lexus", 103) ) ;







-- Here is an additional tidbit, but probably doesn't affect you.

Duplicates are (kinda) ok, as long as the VALUE is the same.
Aka, you would not want Lexus listed twice, with one of the values being 103, and another one being 110 for example.


No matter if you pick the first or second "Lexus", you'll get 103 as the value.




I have an edit page that contains a listbox. I want to select the items in it that were passed from the previous page, but have them at the top of the list box. is there a way to do that/

so for example:
on my main page I have in my grid

BMW, Mercedes, Lexus

when I click edit, I want
BMW, Mercedes, Lexus selected in my listbox (which I have) but at the top so I don't have to scroll looking for them.
Even though they may not be at the top when the list is bound, if they're selected I want them first.

Is there a way to do this?
 

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,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top