From my controller I have passed value module to view
public ActionResult Details(long id, string owner)
{
var module = _ownedModuleRepositor
Try adding a space:
<dt>Ownership End Date</dt>
<dd>
@if (Model.End != null)
{
@Model.End
}
else
{
@:
}
</dd>
Won't a ternary operation work here:
@(Model.End != null ? Model.End.ToString() : "")
you can use C# null coalescing operator:
@(Model.End?.ToString("dd/MM/yyyy") ?? "Date is Empty")
recently i had this issue when user inserted null value in date column
which lead to this error:
System.InvalidOperationException: Nullable object must have a value
to solve this instead of DisplayFor
just use below code in your view , so if the column value is null it will display Date is Empty
<td>
@(item.Startdate.HasValue ? item.Startdate.Value.ToString("dd/MM/yyyy") : "Date is Empty")
</td>
further reading this and this for model
hope helps someone.