The
ASP.NET MVC Preview 5 has provided the functionality to add a default
option label for DropDownList control. For adding a default
option label, provide the default label as the first argument of the
DropDownList helper method. This will render the default option label element with its value attribute equal to an empty string, but with its inner text as the value that you provide.
How do you get it so a blank option will show in the list? If I put a string.Empty there it doesn't add the blank option.
well, i have being looking for information about how to use a dropdownlist in asp.net mvc and the answer is always the same, and the problem that i have is that when i run the application in VS , it´s send to me and error that say "que no se encontro ningun metodo de extensión en DropdownList" if someone can help me please do.
my email is tere-1512@hotmail.com
where's the example
Ok when I first read this I was ready to complain :P
I thought this empty string would break my Binding in the Controller method for int types that are linked to the drop down.
Then I tested it real quick to get the error for complaining....
Dangit - it returns 0, just like I wanted.
Is this just some black magic in the background that is doing a cast from empty.string to 0 in the background ?
How do you get it so a blank option will show in the list? If I put a string.Empty there it doesn't add the blank option.
Add like this
This works whether you are using static values or dynamic values