views:

107

answers:

1

I have a dropdown list on my asp.net mvc site:

<%= Html.DropDownList("CustCodes") %>

My controller:

 ICallService sc = new CallService();
 IList<CustCode> custCodes = sc.GetCustCodes();
 ViewData["CustCodes"] = new SelectList(custCodes, "ID", "Name");

What I want is once the dropdown is displayed to either have a blank entry at the top or an option that says "Select a Customer". Do I need to use jquery to do this or is there something built into the DropDowList helper that I'm missing?

Thanks.

+2  A: 

Use an override that contains an option label.

 <%= Html.DropDownList("CustCodes",
                       ViewData["CustCodes"] as SelectList,
                       "Select a Customer",
                       null ) %>
tvanfosson