Click here to Skip to main content
15,895,782 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi,
I am trying To add "Select Option" item in dropdown menu.

My data is coming from sql through a data source
But it directly displays item list.

for eg:

Item1
Item2
Item3
Item4



how do i add "Select Item" option at first
Posted

It depends how you are creating your dropdown which you haven't shown us so it's hard to give a specific answer, but it'll be something like this

XML
<asp:DropDownList ID="DropDownList1" runat="server" AppendDataBoundItems="true">
    <asp:ListItem Value="" Text="Select Option" />
</asp:DropDownList>


The important attribute to add is "AppendDataBoundItems"
 
Share this answer
 
v2
Comments
Ajay Mestry 28-May-15 7:35am    
Thanks. Your Answer Helped me a lot..
Thankyou so much..
HI Ajay,

Please try this,

comboboxname.Items.Insert(0, New ListItem("-- Select --", ""))

Thanks,
Aniket
 
Share this answer
 

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