ASPForums.Net RSS Feedhttp://www.aspforums.net/Handlers/RSS.ashxLatest additions to the content that appears on ASPForums.Net(c) 2019 www.aspforums.com. All rights reserved.ASP.Net MVC DropDownList HttpPost Error: Value cannot be null. Parameter name: items<p>Hi <a class="username" rel="pankaj04"> pankaj04</a>,</p> <p>In the Post method before returning to the View() assign the ViewBag.deptList value again.</p> <pre class="brush: csharp">[HttpPost] public ActionResult alumniSurvery(FormCollection frm) { ViewBag.deptList = bindDepartment(); return View(); }</pre> <p>Check the below example.</p> <p><strong><span style="text-decoration: underline;">Model</span></strong></p> <pre class="brush: csharp">public class DepartmentModel { public string deptId { get; set; } public string deptName { get; set; } }</pre> <p><strong><span style="text-decoration: underline;">Controller</span></strong></p> <pre class="brush: csharp">public class HomeController : Controller { // GET: /Home/ public ActionResult Index() { return View(); } private List&lt;Models.DepartmentModel&gt; bindDepartment() { List&lt;Models.DepartmentModel&gt; deptList = new List&lt;Models.DepartmentModel&gt;(); Models.DepartmentModel dm = new Models.DepartmentModel(); dm.deptId = &#34;1&#34;; dm.deptName = &#34;Computer&#34;; deptList.Add(dm); dm = new Models.DepartmentModel(); dm.deptId = &#34;2&#34;; dm.deptName = &#34;IT&#34;; deptList.Add(dm); return deptList; } public ActionResult alumniSurvey() { TempData[&#34;deptList&#34;] = bindDepartment(); return View(); } [HttpPost] public ActionResult alumniSurvey(FormCollection frm) { string department = frm[&#34;department&#34;]; TempData[&#34;SelectedDepartment&#34;] = department; TempData[&#34;deptList&#34;] = bindDepartment(); return View(); } }</pre> <p><strong><span style="text-decoration: underline;">View</span></strong></p> <pre class="brush: html">&lt;div&gt; &lt;%using (Html.BeginForm(&#34;alumniSurvey&#34;, &#34;Home&#34;, FormMethod.Post)) { %&gt; &lt;div class=&#34;form-group&#34;&gt; &lt;%{%&gt; &lt;%:Html.DropDownList(&#34;department&#34;, new SelectList((List&lt;DepartmentModel&gt;)TempData[&#34;deptList&#34;], &#34;deptId&#34;, &#34;deptName&#34;), &#34;-- Select Department --&#34;, new { })%&gt; &lt;%:Html.Hidden(&#34;hid_department&#34;)%&gt; &lt;%:Html.Hidden(&#34;hid_course&#34;)%&gt; &lt;%} %&gt; &lt;/div&gt; &lt;input type=&#34;submit&#34; value=&#34;Save&#34; /&gt; &lt;br /&gt; &lt;%} %&gt; &lt;%if (TempData[&#34;SelectedDepartment&#34;] != null) {%&gt; &lt;%=TempData[&#34;SelectedDepartment&#34;] %&gt; &lt;% } %&gt; &lt;/div&gt;</pre> <p><strong><span style="text-decoration: underline;">Screenshot</span></strong></p> <p><img src="https://i.imgur.com/1L1udow.gif" alt="" width="169" height="75" /></p>https://www.aspforums.net:443/Threads/974103/ASPNet-MVC-DropDownList-HttpPost-Error-Value-cannot-be-null-Parameter-name-items/https://www.aspforums.net:443/Threads/974103/ASPNet-MVC-DropDownList-HttpPost-Error-Value-cannot-be-null-Parameter-name-items/Wed, 21 Aug 2019 04:54:15 GMT