0

I have created the following validation class :-

public class ProcessotInfo_Validation
    {

        public Nullable<double> SPEED { get; set; }
    }
}

But currently by default the field will be required, and I am unable to submit the form unless I enter a vale fo th SPEED field. Can anyone advice what is wrong ?

The field on the view is rendered using the following code:-

<div >
    <span class="f">CPU Speed (In MHz)  </span> 

   @Html.EditorFor(model =>model.SystemInfo.ProcessorInfoes.FirstOrDefault().SPEED)
    @Html.ValidationMessageFor(model =>model.SystemInfo.ProcessorInfoes.FirstOrDefault().SPEED)

</div>
John John
  • 1
  • 72
  • 238
  • 501
  • I am not sure if this is the answer or not but you can use DataAnnotations to mark a field as not being required. Does that help with what you are tying? – noggin182 Oct 24 '13 at 13:40
  • but i am trying to figure out why it is marked as Required. and which data annotation i can use to mark the field as not required? – John John Oct 24 '13 at 13:59

1 Answers1

-2

read it Nullable property to entity field, Entity Framework through Code First

Community
  • 1
  • 1
  • Err... have you read what you've typed? You've suggested creating a nullable int called 'double' and missed a bracket. BTW: Nullable and double? are exactly the same, so I think what you might have been asking him to do still wouldn't help – noggin182 Oct 24 '13 at 13:42