select listbox

  • Thread starter Thread starter Mike
  • Start date Start date
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?
 
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?
 
Back
Top