Adding Entries to A DropDown ListBox
-
Hi All: This is an ASP.NET ,Windows,VB.NET application that i am talking about.. I have a peculiar Challenge and need a work around.There is a form that my application uses, which has a drop down list being populated at run time. Apart from the data being populated i want the dropdownlist to have the option "Select one by clicking" as the default selected option in this listbox.I have managed to do it by the commands
**txt_listbox.items.add**
and then selected the option using**txt_listbox.items.findbytext("---").selected=true**
But then the challenge is this option though gets selected is the last item on my dropdown listbox after all the data from the database..But i want it to be the first..How do i do that. If i try adding this entry and then populating from the database the database entries wipe out this entry. I can Instead of using a datasource simply get the dataset and then do a iteration though the values in the dataset and do the add items command.But then my dropdown list box displays one value(ie CustomerName) and binds to another value in the dataset (ie CustomerID).I will lose this functionality when i iterate.So right now i need somE work around for this. Any help is greatly appreciated.. Regards Pradhip.S If a Building is Completed then why do they call it BUILDING ?? -
Hi All: This is an ASP.NET ,Windows,VB.NET application that i am talking about.. I have a peculiar Challenge and need a work around.There is a form that my application uses, which has a drop down list being populated at run time. Apart from the data being populated i want the dropdownlist to have the option "Select one by clicking" as the default selected option in this listbox.I have managed to do it by the commands
**txt_listbox.items.add**
and then selected the option using**txt_listbox.items.findbytext("---").selected=true**
But then the challenge is this option though gets selected is the last item on my dropdown listbox after all the data from the database..But i want it to be the first..How do i do that. If i try adding this entry and then populating from the database the database entries wipe out this entry. I can Instead of using a datasource simply get the dataset and then do a iteration though the values in the dataset and do the add items command.But then my dropdown list box displays one value(ie CustomerName) and binds to another value in the dataset (ie CustomerID).I will lose this functionality when i iterate.So right now i need somE work around for this. Any help is greatly appreciated.. Regards Pradhip.S If a Building is Completed then why do they call it BUILDING ??Pradhip wrote: But i want it to be the first..How do i do that. Use the Insert method passing 0 as the index. Cheers, Tom Archer Author - Inside C#, Visual C++.NET Bible