Display empty textbox using Html.TextBoxFor on a not-null property in an EF entity.

Posted by hungster on Stack Overflow See other posts from Stack Overflow or by hungster
Published on 2010-04-24T09:07:41Z Indexed on 2010/04/24 9:13 UTC
Read the original article Hit count: 659

I am using Entity Framework (v4) entities. I have an entity called Car with a Year property of type integer. The Year property does not allow NULL. I have the following in my Create view:

<%= Html.TextBoxFor(model => model.Year) %>

I am required to return a new Car object (due to other requirements) in my HttpGet Create action in the CarController.

Currently, a zero is displayed in the Year textbox because the Year property does not allow NULL. I would like to display an empty textbox in the Create view. How do I do this?

© Stack Overflow or respective owner

Related posts about asp.net-mvc-2

Related posts about entity-framework