title: How to Hide Table in MVC View when there is No Data?
body: <p>I am populating my datatable using Linq.</p>
  
  <p>I have hard-coded headers. And populating body columns with Linq. Following is my code.</p>
  
  <pre><code>&lt;table id="tableID"&gt;
                  &lt;thead&gt;
                      &lt;tr&gt;
                          &lt;th&gt;Name&lt;/th&gt;
                          &lt;th&gt;ID&lt;/th&gt;
                          &lt;th style="width:2%;"&gt;&lt;/th&gt;
                      &lt;/tr&gt;
                  &lt;/thead&gt;
                  &lt;tbody&gt;
                       @if(Model.Values !=null)
                  {
                      foreach(var value in Model.Values)
                      {   
                          &lt;tr&gt;
                              &lt;td&gt;@value.Name&lt;/td&gt;
                              &lt;td&gt;@value.ID&lt;/td&gt;
                          &lt;/tr&gt;
                      }
                  }
  
  
                  &lt;/tbody&gt;
              &lt;/table&gt;
  </code></pre>
  
  <p>What I am thinking to do here, if there is no data table should not be visible.I thought of moving my conditional check if model is returning null prior to table creation but it will throw exception. I am fairly new to MVC. Any suggestion is appreciated. 
  Thank you</p>