Note that there are some explanatory texts on larger screens.

plurals
  1. PONo parameterless constructor defined for this object?
    primarykey
    data
    text
    <p>I got above subjected error while POST the form and I think the root cause of subjected error is "DropDownListFor", where plural SelectList twice called, If Yes, please suggest the solution?</p> <p>If I change from "x=>x.Values" to "x=>x.Name" then also get error "There is no ViewData item of type 'IEnumerable' that has the key 'DDLView.Name'."</p> <p><strong>Editor Template</strong></p> <pre><code>@model DropDownListViewModel @Html.LabelFor(x=&gt;x.Values, Model.Label) @Html.DropDownListFor(x=&gt;x.Values, Model.Values) </code></pre> <p><strong>View Model</strong></p> <pre><code>public class HomePageViewModel { public DropDownListViewModel DDLView { get; set; } } public class DropDownListViewModel { public string Label { get; set; } public string Name { get; set; } public SelectList Values { get; set; } } </code></pre> <p><strong>Controller</strong></p> <pre><code>public ActionResult Index() { HomePageViewModel homePageViewModel = new HomePageViewModel(); homePageViewModel.DDLView = new DropDownListViewModel { Label = "drop label1", Name = "DropDown1", Values = new SelectList( new[] { new {Value = "1", Text = "text 1"}, new {Value = "2", Text = "text 2"}, new {Value = "3", Text = "text 3"}, }, "Value", "Text", "2" ) }; } [HttpPost] public ActionResult Index(HomePageViewModel model) { return View(model); } </code></pre> <p><strong>View</strong></p> <pre><code>@model Dynamic.ViewModels.HomePageViewModel @using (Html.BeginForm()) { @Html.EditorFor(x=&gt;x.DDLView) &lt;input type="submit" value="OK" /&gt; </code></pre> <p>}</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload