michael1174
asked on
Default to blank for drop down list using ASP.NET c#
I am populating a drop down list in ASP.NET using c#. It populates fine. I just want the default entry to be blank. What is the easiest way to accomplish this?
Thanks!
Thanks!
dropdown1.Items.Insert(0, "");
Are you binding your list to anything ? Whether you are or not all you need to do is add an empty item as the first entry in the list:
<asp:DropDownList ID="blah" runat="server">
<asp:ListItem Text="" Value="" />
</asp:DropDownList>
The only caveat is if you're binding to the list. If you are binding then you need to add the "AppendBoundItems" attribute to the DropDownList.
<asp:DropDownList ID="blah" runat="server">
<asp:ListItem Text="" Value="" />
</asp:DropDownList>
The only caveat is if you're binding to the list. If you are binding then you need to add the "AppendBoundItems" attribute to the DropDownList.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
thanks everyone! mrichmon's solution worked perfectly for me.
@: mrichmon
Your solution helped me as well - Thx !!
Your solution helped me as well - Thx !!
You muse insert a blank one item after the dropdown list is populated and make it selected
Regards,
Martin