title: Avoid to show Null or specific values to razor view engine
body: <p>I am working on asp.net mvc3 web application using MS Sql server 2008 express rc2. In my app I have two different brands in DB and one of them have few Null or 'unknown' values (e.g. 'unknown' is added to DB instead of Null). My question is how to pass only non null values to View Engine instead of using If/Else statements in View?</p>
  
  <p>in controller:</p>
  
  <pre><code>var model = _data.GetViewModel(query);
          if (model != null)
          {                
              return View(model);
          }
          else
              return View("Error");
  </code></pre>
  
  <p>in ViewModel;</p>
  
  <pre><code>    public int Id { get; set; }
      public string Query { get; set; }
      public string Brand { get; set; }
      public string Family { get; set; }
      public string Type { get; set; }
  </code></pre>
  
  <p>in Model:</p>
  
  <pre><code>    public ViewModel GetViewModel(string query)
      {
          var data = _comp.Get(p =&gt; p.Query == query);
          if (data == null) return null;
          return new ViewModel
          {
              Id = data.id,
              Brand = data.brand,
              Family = data.family,
              Type = data.type
          };
     }
  </code></pre>
  
  <p>in View (I am currently using If statement):</p>
  
  <pre><code>@if (Model.Brand != null)
  {
  &lt;span class="brand"&gt;@Model.Brand&lt;/span&gt; 
  }
  
  @if (Model.Family != null)
  {
  &lt;span class="family"&gt;@Model.Family&lt;/span&gt; 
  }
  
  @if (Model.Type != null)
  {
  &lt;span class="type"&gt;@Model.Type&lt;/span&gt;
  }
  </code></pre>
  
  <p>Note: I want to avoid If statement because there are too many values in the Database of each brand, and many of the them are Null, So I don't want to generate Html for those Null values. I am using If/Else statement like above code, and for checking too many values in View using If, it costs Memory on server and processor, and it also slow down server response time.</p>
  
  <p>I want to have an alternative method to do this. Should I use Partial views or anything else?
  Please Please help me to solve this, Your help is very appreciated.
  Thanks and Regards. </p>