views:

290

answers:

1

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?

A: 

Try this instead:

Html.TextBox("Year", "")
Cristi Todoran
I could do it that way but I prefer to use Html.TextBoxFor.
hungster