I am using a simple MVC 4 application using Entity Framework.
- In my View I am displaying data from of a table using webgrid.
- View Also has Textboxes(EditorFor) for saving any new record in the table.
- I am using partial view for the Textboxes, as in the beginning when the page is launched, the textboxes should remain empty.
- Out of 5, two columns are of integer types.
In order to make the textboxes empty initially I am using a new object as -
@if (!dataGrid.HasSelection) {
Datamodel = new EntityFrDemo.Models.FacultyDetails { DepartmentID = 0, Name = "", Subject = "", YrsExp = 0, Email = "" };Html.RenderPartial("~/Views/Shared/_FacultyDetails.cshtml", Datamodel); }
//------------------------------------------------------------------------
//-----------------------------------------------------------------------------

- So I am able to make my boxes empty, however for the Integer type boxes '0' is coming, as I can only assign zero.
So How can I override/superimpose the integer value type boxes to empty string type so that boxes remains empty only in case when no row is selected i.e. in initial stage...?
int?instead ofint.