Nullable enum in html helper
        Posted  
        
            by 
                Fabien Piron
            
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by Fabien Piron
        
        
        
        Published on 2012-12-14T10:44:10Z
        Indexed on 
            2012/12/14
            11:04 UTC
        
        
        Read the original article
        Hit count: 294
        
I have a view model that contains enum with nullable type like this one :
public StudyLevel? studyLevel { get; set; }
I have made custom html helper to display a dropdownlist for rendering the enum into the view, the nullable case is displayed using
<option value="null">No value</option>
the problem is that when i submit the form modelstate give me the error :
studylevel cannot be "null" .
Could you suggest me any way to help me handle the nullable type in the view ?
© Stack Overflow or respective owner