Link to home
Start Free TrialLog in
Avatar of michael1174
michael1174Flag for United States of America

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!
Avatar of mmarinov
mmarinov

Hello michael1174,

You muse insert a blank one item after the dropdown list is populated and make it selected

Regards,
Martin
dropdown1.Items.Insert(0, "");
Avatar of Carl Tawn
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.
ASKER CERTIFIED SOLUTION
Avatar of mrichmon
mrichmon

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of michael1174

ASKER

thanks everyone! mrichmon's solution worked perfectly for me.

@: mrichmon
Your solution helped me as well - Thx !!