KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I have this property in my view model: [DisplayName("Region")] public int? RegionId { get; set; } I pass my view model to my controller, and it fails at ModelState.IsValid if RegionId is null. If I pass an integer to it, it works fine. The error message is: The value 'null' is not valid for Region I've also tried calling this before I check ModelState.IsValid , but I get the same error: if (viewModel.RegionId == null) viewModel.RegionId = (int?)null; What's the problem here? Why can't I assign null to something that is nullable?
Tags (comma-separated)
Save Edits
Cancel