I'm trying to develop a simple partial view:
@model Nullable<DateTime>
@if (Model == null)
{
<span>Active</span>
}
else
{
<span>Resigned on @Model.GetValueOrDefault().ToShortDateString()</span>
}
and use it from another view:
@Html.Partial("ViewTemplates/UserStatus",user.ResignDate)
The view works perfectly unless it is a Nullable<T>.
I receive the error:
The model item passed into the dictionary is of type 'System.Collections.Generic.List
1[Models.UserModel]', but this dictionary requires a model item of type 'System.Nullable1[System.DateTime]'.
Of course user.ResignDate is a nullable date time.
Any ideas?
Thanks