title: Hide a DropDownList in MVC4
body: <p>I have a Simple query to ask..</p>
  
  <p>I have a DropdownList,and it holds data which depends on values from DATABASE.</p>
  
  <p>Now their can be 2 scenario:-</p>
  
  <p>1)- DropdownList holds value(Not empty)
  2)-DropdownList Doesnt hold values(Empty)</p>
  
  <p>Now what I want is,I want to Hide the DropdownList and the LABEL(Select UserName) if it EMPTY..I hope am clear..!!</p>
  
  <p>I tried This to hide DropDownList but it dint Work so How Can I hide both the Label and the DropDownList-</p>
  
  <pre><code>&lt;label&gt;
                      Select UserName :&lt;/label&gt;
                  @if (@ViewBag.UserName.Items.Count == 0)
                  {
                      &lt;div id="uniform-undefined" class="selector" style="margin-right: 60px; margin-left: 10px;"&gt;
                          @Html.DropDownList("UserName", null, new { @visible= false })
                      &lt;/div&gt;
                  }
  </code></pre>
  
  <p>I tried this-I disabled my DropdownList when it gets empty and this code works..HOW?</p>
  
  <pre><code>@if (@ViewBag.UserName.Items.Count == 0)
                  {
                      &lt;div id="uniform-undefined" class="selector" style="margin-right: 60px; margin-left: 10px;"&gt;
                          @Html.DropDownList("UserName", null, new { @disabled = true })
                      &lt;/div&gt;
                  }
  </code></pre>