Quantcast
Channel: Fluent Validation for .NET
Viewing all articles
Browse latest Browse all 1917

New Post: Nullable SelectedID of the DropDownList has always a TRUE ModelState although the ID is Null

$
0
0

Hello Jeremy,

sorry for the late reply. Have had no time to answer earlier.

I have ripped my application to show only one delete releaseviewmodel dialog.

It is still as I said at the beginning.

1.) Using a DropDownListFor the bound SelectedId is a nullable integer.

2.) The controller also accepts a nullable integer.

3.) Initially the DropDownListFor is bound to an empty List<ReleaseViewModel>

4.) Confirming the deletion of an empty DropDownListFor and the controller gets a null value for the selectedId

5.) BUT why is the Modelstate.IsValid  TRUE ?

6.) I have setup the RuleFor().NotEmpty for the SelectedId

Here is the sample Visual Studio 2010 project. I have packed the solution as a 9,2 MB .7zip file.

http://www.sendspace.com/file/wk1si6

In order that  you can run this solution you should do an update with the nuget package manager to get missing packages

in the case it does not build.

I would be pleased if you could have a look at it and tell me what is wrong.

Thank you very much for your time.

Cheers,

BastienPascal


Viewing all articles
Browse latest Browse all 1917


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>