I have several ‘lookup’ fields in my models where I don’t want nulls, but on Create views it is very inconvenient that these fields keep defaulting to the first value in teh Select lists. What can I do to avoid this?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
If I understand correctly you want the dropdown to show something like
And then throw a validation error if no selection is done.
You can do that by simply specifing a default value in the
Html.DropDownListForIn your model you will have the
RequiredAttributeor in the controller you do the validation needed