Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / August 2007

Tip: Looking for answers? Try searching our database.

select listbox

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Mike - 31 Aug 2007 17:53 GMT
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?
sloan - 31 Aug 2007 21:15 GMT
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?

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.