title: System.NullReferenceException: Object reference not set to an instance of an object. bootstrap dropdownlist
body: <p>Model</p>
  
  <pre><code>public class Employee
      {
          public int EmployeeID { get; set; }
          public string Title { get; set; }
          [Required(ErrorMessage = "Please enter first name.")]
          [StringLength(500)]
          public string FirstName { get; set; }
          public string MI { get; set; }
          [Required(ErrorMessage = "Please enter last name.")]
          [StringLength(500)]
          public string LastName { get; set; }
          public string Gender { get; set; }
  
          [Required(ErrorMessage = "Please select date of birth.")]
          public Nullable&lt;System.DateTime&gt; DateOfBirth { get; set; }
  
          [Required(ErrorMessage = "Please enter email.")]
          [StringLength(500)]
          [EmailAddress]
          public string Email { get; set; }
  
          [Required(ErrorMessage = "Please enter street.")]
  
          [StringLength(500)]
          public string Street { get; set; }
  
          [Required(ErrorMessage = "Please enter state.")]
          [StringLength(50)]
          public string State { get; set; }
  
          [Required(ErrorMessage = "Please enter city.")]
          [StringLength(50)]
          public string City { get; set; }
  
          [Required(ErrorMessage = "Please enter country.")]
          [StringLength(50)]
          public string Country { get; set; }
  
          [Required(ErrorMessage = "Please enter post code.")]
          [StringLength(6)]
          public string PostCode { get; set; }
  
          [Required(ErrorMessage = "Please enter home phone.")]
          public string HomePhone { get; set; }
  
          [Required(ErrorMessage = "Please enter mobile phone.")]
  
          public string MobilePhone { get; set; }
  
  
      }
  </code></pre>
  
  <p>Controller Method</p>
  
  <pre><code>[HttpPost]
  [ValidateAntiForgeryToken]
  public ActionResult Create(Employee employee)
  {
      if (ModelState.IsValid)
      {
          db.Employees.Add(employee);
          db.SaveChanges();
          return RedirectToAction("Index");
      }
  
      return View(employee);
  }
  </code></pre>
  
  <p>View </p>
  
  <pre><code>@model EmployeeManagementSystem.Models.Employee
  
  @{
      ViewBag.Title = "Create";
  }
  
  
  &lt;h2&gt;Create&lt;/h2&gt;
  
  &lt;div class="row-fluid"&gt;
      &lt;div class="span12"&gt;
          @using (Html.Bootstrap().Begin(new Form().Id("CreateEmployee").Type(FormType.Inline)))
          {
  
              @Html.AntiForgeryToken()
  
              &lt;div class="span12"&gt;
  
                  &lt;fieldset&gt;
                      &lt;div class="span4"&gt;
  
                          &lt;legend&gt;Employee Info&lt;/legend&gt;
  
                          @Html.Bootstrap().ControlGroup().TextBoxFor(x =&gt; x.FirstName).Size(InputSize.BlockLevel).ShowValidationMessage(true, HelpTextStyle.Block)
                          @Html.Bootstrap().ControlGroup().TextBoxFor(x =&gt; x.LastName).Size(InputSize.BlockLevel).ShowValidationMessage(true, HelpTextStyle.Block)
                          @Html.Bootstrap().ControlGroup().DropDownListFor(m =&gt; m.Gender, ViewBag.GenderList as SelectList).Size(InputSize.BlockLevel).ShowValidationMessage(true, HelpTextStyle.Block)
                          @Html.Bootstrap().ControlGroup().Class("input-append date").TextBoxFor(x =&gt; x.DateOfBirth).Size(InputSize.BlockLevel).AppendIcon(Icons.calendar).ShowValidationMessage(true, HelpTextStyle.Block)
                          @Html.Bootstrap().ControlGroup().TextBoxFor(x =&gt; x.Email).Size(InputSize.BlockLevel).ShowValidationMessage(true, HelpTextStyle.Block)
                      &lt;/div&gt;
                      &lt;div class="span8 "&gt;
                          &lt;legend&gt;Contact Details&lt;/legend&gt;
  
                          @Html.Bootstrap().ControlGroup().TextBoxFor(x =&gt; x.Street).Size(InputSize.BlockLevel).ShowValidationMessage(true, HelpTextStyle.Block)
  
                          &lt;div class="span6" style="margin-left:0px"&gt;
                              @Html.Bootstrap().ControlGroup().TextBoxFor(x =&gt; x.City).Size(InputSize.BlockLevel).ShowValidationMessage(true, HelpTextStyle.Block)
                              @Html.Bootstrap().ControlGroup().TextBoxFor(x =&gt; x.State).Size(InputSize.BlockLevel).ShowValidationMessage(true, HelpTextStyle.Block)
                              @Html.Bootstrap().ControlGroup().TextBoxFor(x =&gt; x.HomePhone).Size(InputSize.BlockLevel).ShowValidationMessage(true, HelpTextStyle.Block).HtmlAttributes(new Dictionary&lt;string, Object&gt; { { "data-mask", "(99999)(999999)" } })
                          &lt;/div&gt;
                          &lt;div class="span6"&gt;
                              @Html.Bootstrap().ControlGroup().TextBoxFor(x =&gt; x.PostCode).Size(InputSize.BlockLevel).ShowValidationMessage(true, HelpTextStyle.Block)
                              @Html.Bootstrap().ControlGroup().TextBoxFor(x =&gt; x.Country).Size(InputSize.BlockLevel).ShowValidationMessage(true, HelpTextStyle.Block)
                              @Html.Bootstrap().ControlGroup().TextBoxFor(x =&gt; x.MobilePhone).Size(InputSize.BlockLevel).ShowValidationMessage(true, HelpTextStyle.Block).HtmlAttributes(new Dictionary&lt;string, Object&gt; { { "data-mask", "+99 (9999)(999999)" } })
  
  
                          &lt;/div&gt;
                      &lt;/div&gt;
                  &lt;/fieldset&gt;
  
                  @Html.Bootstrap().SubmitButton().Style(ButtonStyle.Primary)
                  @Html.Bootstrap().ActionLinkButton("Cancel", "Index").Style(ButtonStyle.Default)
  
  
              &lt;/div&gt;
          }
      &lt;/div&gt;
  &lt;/div&gt;
  
  @section Scripts {
      &lt;script type="text/javascript"&gt;
          $(document).ready(function () {
              //$('[rel=tooltip]').tooltip();
  
              $('#CreateEmployee .input-append.date').datepicker({
                  startView: 2,
                  autoclose: true
              });
  
          });
      &lt;/script&gt;
  
      @Scripts.Render("~/bundles/jqueryval")
      @Scripts.Render("~/bundles/BootstrapFormHelpersJS")
      @Styles.Render("~/Content/BootstrapFormHelpersCSS")
  }
  </code></pre>