Handling null values in asp.net MVC dropdowns?

You don't need to write a helper. It already exists. Use one of the Html.

Select overloads which takes an optionLabel argument. Set that to "(Not Specified).

You don't need to write a helper. It already exists. Use one of the Html.

Select overloads which takes an optionLabel argument. Set that to "(Not Specified)".

1 That was too simple. :) I guess I didn't grok the intellisense...it says, "Provides the text for a default empty valued option, if it is not null. " That would have no meaning to me at all if I didn't have a good understanding of markup, although if that were the case I probably shouldn't be playing in the MVC sandbox anyway.

Also, the phrase "if it is not null" seems backwards. Anyway, thanks for the help. Sometime one just needs to ask.

– Robert Harvey? May 22 '09 at 17:24 1 I assume it is referring to the option label when it states "if it is not null". The way this seems to work is, if you specify null (or another overload that doesn't set it) it does not show the blank option at all.

Otherwise, whatever you specify - including an empty string, which is not null - is used as the blank option text. – GalacticCowboy May 22 '09 at 17:35 Yeah, the description could be better, there. – Craig Stuntz May 22 '09 at 17:36.

Also, whatever field you are binding to must be nullable - in this case, either a string, or a nullable int.

The application is a lookup field in a database, where the primary key is in a lookup table, i.e. Categories, and the foreign key is in another table, i.e.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions