title: Checking if the value of type DateTime is null in view and showing blank if null
body: <p>From my controller I have passed value module to view</p>
  
  <pre><code>    public ActionResult Details(long id, string owner)
      {
          var module = _ownedModuleRepository.GetModuleDetails(id, owner);
  
          return View(module);
      }
  </code></pre>
  
  <p>I've shown the value it contains in view as follows</p>
  
  <pre><code>    &lt;dt&gt;ID&lt;/dt&gt;
      &lt;dd&gt;@Model.Id&lt;/dd&gt;
  
      &lt;dt&gt;Module ID&lt;/dt&gt;
      &lt;dd&gt;@Model.ModuleId&lt;/dd&gt;
  
       &lt;dt&gt;Owner&lt;/dt&gt;
      &lt;dd&gt;@Model.Owner&lt;/dd&gt;
  
      &lt;dt&gt;Module Type&lt;/dt&gt;
      &lt;dd&gt;@Model.TypeName&lt;/dd&gt;
  
      &lt;dt&gt;Module Kind&lt;/dt&gt;
      &lt;dd&gt;@Model.KindName&lt;/dd&gt;
  
      &lt;dt&gt;Ownership Start Date&lt;/dt&gt;
      &lt;dd&gt;@Model.Start&lt;/dd&gt;
  
      &lt;dt&gt;Ownership End Date&lt;/dt&gt;
      &lt;dd&gt;@Model.End&lt;/dd&gt;
  
      @foreach (var properties in Model.Properties)
      {
          &lt;dt&gt;Property Name&lt;/dt&gt;
          &lt;dd&gt;@properties.Name&lt;/dd&gt;
          &lt;dt&gt;Property Value&lt;/dt&gt;
          &lt;dd&gt;@properties.Value&lt;/dd&gt;
      }
  </code></pre>
  
  <p>Currently <strong>@Model.End</strong> is null, it is of DateTime type and I had set it to be nullable in viewmodel.
  Since it is null, this is what i'm getting in view</p>
  
  <p><img src="https://i.stack.imgur.com/CiRNd.png" alt="enter image description here"></p>
  
  <p>As you can see, the value of Ownership End Date is taking the value of Property Name from below. How can I set it to empty if the <em>@Model.End is null</em>?</p>
  
  <p><strong>Edit 1:</strong></p>
  
  <p>My model</p>
  
  <pre><code>public class OwnedModuleDetails
  {
      public long Id { get; set; }
  
      public string ModuleId { get; set; }
  
      public string Owner { get; set; }
  
      public string KindName { get; set; }
      public string TypeName { get; set; }
  
      public DateTime Start { get; set; }
  
      public DateTime? End { get; set; }
  
      public IEnumerable&lt;Property&gt; Properties { get; set; }
  }
  </code></pre>
  
  <p>Method from the repository</p>
  
  <pre><code>     public OwnedModuleDetails GetModuleDetails(long id, string owner)
          {
  // ReSharper disable ImplicitlyCapturedClosure
              var module = (_dbSis.OwnedModules.Where(t =&gt; t.Id == id).Select(m =&gt; new OwnedModuleDetails
  // ReSharper restore ImplicitlyCapturedClosure
              {
                  Id = id,
                  ModuleId = m.ModuleId,
                  TypeName = m.ModuleType.TypeName,
                  KindName = m.ModuleType.ModuleKind.KindName,
                  Owner = owner,
                  Start = m.Start,
                  End = m.End,
                  Properties = m.PropertyConfiguration.PropertyInstances.Select(
                      x =&gt; new Property { Name = x.Property.Name, Value = x.Value })
              }));
  
              return (module.FirstOrDefault());
          }
  </code></pre>