Click here to Skip to main content
15,900,725 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hello all,

I have a dropdownlist which is filled with data from dataset,
now i want to add test -- select -- on the first place, but at the same time i don't want to disturb data which came from my dataset to dropdownlist...
please help

Thanks in Advance
Posted

As par your requirement, try below code :

DropDownList1.Items.Insert(0,new ListItem("--Select--","12"));
 
Share this answer
 
Comments
sunil mali 3-May-13 9:12am    
Thanks bhushan this is what i want...Thanks :)
Bhushan Shah1988 3-May-13 9:20am    
you are welcome. Do vote.
after databind add following code :

C#
DropDownList1.Items.Insert(0, "--Select--");
 
Share this answer
 
Comments
sunil mali 3-May-13 8:56am    
Hii bhushan,

This will add item text property and value property as --Select--
i also want to give some value property to same item lets say 12 as value to this item


ex:-
it should display
droplst.SeletedItem.text should give me --Select--
and droplst.selectedValue.text should give me 12
Improve solution Permalink Posted 2 secs ago
sunil_mali1.1K

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900