title: MVC3 asp.net error: Value cannot be null. Parameter name: items on dropdownlist
body: <p>I am getting a dump ONLY in the server and not in my local system when trying to post the data. There is a page which submits some value to the database. I have also modeled the dropdown in the page as mandatory. However, when clicking on "Create", instead of giving an error like "Missing"; it throws a dump. </p>
  
  <p>Dump trace: </p>
  
  <pre><code>Value cannot be null.
  Parameter name: items
  
  Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 
  
  Exception Details: System.ArgumentNullException: Value cannot be null.
  Parameter name: items
  
  Source Error: 
  
  
  Line 65:         &lt;/div&gt;
  Line 66:         &lt;div class="editor-field"&gt;
  Line 67:             @Html.DropDownListFor(x =&gt; x.ProjectName, new SelectList(Model.ProjectDetail, "ProjectName", "ProjectName"),"")
  Line 68:             &lt;span runat="server" style="color:Red;" visible="false"&gt; *&lt;/span&gt;
  Line 69:             @Html.ValidationMessageFor(model =&gt; model.ProjectName)
  
  Source File: d:\hosting\11178048\html\fbpm\fbpm\Views\User\Create.cshtml    Line: 67 
  </code></pre>
  
  <p>Stack Trace: </p>
  
  <pre><code>[ArgumentNullException: Value cannot be null. Parameter name: items]   System.Web.Mvc.MultiSelectList..ctor(IEnumerable items, String dataValueField, String dataTextField, IEnumerable selectedValues)
  +289714    System.Web.Mvc.SelectList..ctor(IEnumerable items, String dataValueField, String dataTextField) +19    ASP._Page_Views_User_Create_cshtml.Execute() in d:\hosting\11178048\html\fbpm\fbpm\Views\User\Create.cshtml:67    System.Web.WebPages.WebPageBase.ExecutePageHierarchy() +197    System.Web.Mvc.WebViewPage.ExecutePageHierarchy() +81    System.Web.WebPages.StartPage.RunPage() +17
  </code></pre>
  
  <p>The Controller code:</p>
  
  <pre><code>public ActionResult Create()
  {
      var model = new UserDetail
      {
          ProjectDetail = db1.ProjectDetails.ToList()
      };
      return View(model);
  } 
  
  //
  // POST: /User/Create
  
  [HttpPost]
  public ActionResult Create(UserDetail userdetail)
  {
      if (ModelState.IsValid)
      {
          db.UserDetails.Add(userdetail);
          db.SaveChanges();
          return RedirectToAction("SearchCust");  
      }
  
      return View(userdetail);
  }
  </code></pre>
  
  <p>The view code:</p>
  
  <pre><code>@model fbpm.Models.UserDetail
  
  @{
      ViewBag.Title = "Create Customer";
  }
  
  &lt;h2&gt;Create Customer&lt;/h2&gt;
  
  &lt;script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"&gt;&lt;/script&gt;
  &lt;script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"&gt;&lt;/script&gt;
  
  @using (Html.BeginForm()) {
      @Html.ValidationSummary(true)
      &lt;fieldset&gt;
          &lt;legend&gt;Customer Detail&lt;/legend&gt;
          &lt;div id ="left" style="float:left; width:400px;"&gt;
          &lt;div class="editor-label"&gt;
              @Html.LabelFor(model =&gt; model.UserID)
          &lt;/div&gt;
          &lt;div class="editor-field"&gt;
              @Html.EditorFor(model =&gt; model.UserID)
              &lt;span runat="server" style="color:Red;" visible="false"&gt; *&lt;/span&gt;
              @Html.ValidationMessageFor(model =&gt; model.UserID)
          &lt;/div&gt;
  
          &lt;div class="editor-label"&gt;
              @Html.LabelFor(model =&gt; model.Password)
          &lt;/div&gt;
          &lt;div class="editor-field"&gt;
              @Html.EditorFor(model =&gt; model.Password)
              &lt;span runat="server" style="color:Red;" visible="false"&gt; *&lt;/span&gt;
              @Html.ValidationMessageFor(model =&gt; model.Password)
          &lt;/div&gt;
  
          &lt;div class="editor-label"&gt;
              @Html.LabelFor(model =&gt; model.UserName)
          &lt;/div&gt;
          &lt;div class="editor-field"&gt;
              @Html.EditorFor(model =&gt; model.UserName)
              @Html.ValidationMessageFor(model =&gt; model.UserName)
          &lt;/div&gt;
          &lt;div class="editor-label"&gt;
              @Html.LabelFor(model =&gt; model.PANNo)
          &lt;/div&gt;
          &lt;div class="editor-field"&gt;
              @Html.EditorFor(model =&gt; model.PANNo)
              @Html.ValidationMessageFor(model =&gt; model.PANNo)
          &lt;/div&gt;
          &lt;div class="editor-label"&gt;
              @Html.LabelFor(model =&gt; model.EmailID)
          &lt;/div&gt;
          &lt;div class="editor-field"&gt;
              @Html.EditorFor(model =&gt; model.EmailID)
              @Html.ValidationMessageFor(model =&gt; model.EmailID)
          &lt;/div&gt;
          &lt;br /&gt;
          &lt;p&gt;
              &lt;input type="submit" value="Create Customer" /&gt;
          &lt;/p&gt;
  
          &lt;/div&gt;
          &lt;div id = "left3" style="float:left; width:400px"&gt;
          &lt;div class="editor-label"&gt;
              @Html.LabelFor(model =&gt; model.ProjectName)
          &lt;/div&gt;
          &lt;div class="editor-field"&gt;
              @Html.DropDownListFor(x =&gt; x.ProjectName, new SelectList(Model.ProjectDetail, "ProjectName", "ProjectName"),"")
              &lt;span runat="server" style="color:Red;" visible="false"&gt; *&lt;/span&gt;
              @Html.ValidationMessageFor(model =&gt; model.ProjectName)
          &lt;/div&gt;
          &lt;div class="editor-label"&gt;
              @Html.LabelFor(model =&gt; model.BookedDate)
          &lt;/div&gt;
          &lt;div class="editor-field"&gt;
              @Html.EditorFor(model =&gt; model.BookedDate)
              &lt;span runat="server" style="color:Red;" visible="false"&gt; *&lt;/span&gt;
              @Html.ValidationMessageFor(model =&gt; model.BookedDate)
          &lt;/div&gt;
  
          &lt;div class="editor-label"&gt;
              @Html.LabelFor(model =&gt; model.BookedAmount)
          &lt;/div&gt;
          &lt;div class="editor-field"&gt;
              @Html.EditorFor(model =&gt; model.BookedAmount)
              &lt;span runat="server" style="color:Red;" visible="false"&gt; *&lt;/span&gt;
              @Html.ValidationMessageFor(model =&gt; model.BookedAmount)
          &lt;/div&gt;
  
          &lt;div class="editor-label"&gt;
              @Html.LabelFor(model =&gt; model.Contact1)
          &lt;/div&gt;
          &lt;div class="editor-field"&gt;
              @Html.EditorFor(model =&gt; model.Contact1)
              @Html.ValidationMessageFor(model =&gt; model.Contact1)
          &lt;/div&gt;
  
          &lt;div class="editor-label"&gt;
              @Html.LabelFor(model =&gt; model.Contact2)
          &lt;/div&gt;
          &lt;div class="editor-field"&gt;
              @Html.EditorFor(model =&gt; model.Contact2)
              @Html.ValidationMessageFor(model =&gt; model.Contact2)
          &lt;/div&gt;
          &lt;/div&gt;
          &lt;div id="left1" style="float:left; width:400px;"&gt;
          &lt;div class="editor-field"&gt;
              @Html.HiddenFor(model =&gt; model.Role, new { @readonly = "readonly", @Value = "400" })
              @Html.ValidationMessageFor(model =&gt; model.Role)
          &lt;/div&gt;
          &lt;div class="editor-label"&gt;
              @Html.LabelFor(model =&gt; model.FullAddress)
          &lt;/div&gt;
          &lt;div class="editor-field"&gt;
              @Html.TextAreaFor(model =&gt; model.FullAddress)
              @Html.ValidationMessageFor(model =&gt; model.FullAddress)
          &lt;/div&gt;
  
          &lt;div class="editor-label"&gt;
              @Html.LabelFor(model =&gt; model.State)
          &lt;/div&gt;
          &lt;div class="editor-field"&gt;
              @Html.EditorFor(model =&gt; model.State)
              @Html.ValidationMessageFor(model =&gt; model.State)
          &lt;/div&gt;
  
          &lt;div class="editor-label"&gt;
              @Html.LabelFor(model =&gt; model.Country)
          &lt;/div&gt;
          &lt;div class="editor-field"&gt;
              @Html.EditorFor(model =&gt; model.Country)
              @Html.ValidationMessageFor(model =&gt; model.Country)
          &lt;/div&gt;
  
  
          &lt;/div&gt;
  
      &lt;/fieldset&gt;
  }
  
  &lt;div&gt;
      @Html.ActionLink("Back to List", "SearchCust")
  &lt;/div&gt;
  </code></pre>
  
  <p>I have searched a lot in the net and found that adding a viewbag for the project name in the submit action before returning the view owuld help; but, it didnt. Please can someone help?</p>
  
  <p>Regards</p>