ASP.NET MVC dropdown with a default empty option

The below will prepend string.Empty to the SelectList (or IEnumerable) specified in the ViewData[“Menu”] item. The select will have id and name MenuID.

<%= Html.DropDownList( "MenuID",
                      (IEnumerable<SelectListItem>)ViewData["Menu"],
                      string.Empty ) %>

Documentation: DropDownList method

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)