Note that there are some explanatory texts on larger screens.

plurals
  1. POasp.net mvc model item passed in to dictionary is of type List
    primarykey
    data
    text
    <p>I have a asp.net mvc view which is strongly typed view and i have a controller which returns the ilist user based on the id provided. I am getting the following above error:</p> <p><strong>The model item passed into the dictionary is of type 'System.Collections.Generic.List`1[Data.User]', but this dictionary requires a model item of type 'Data.User'.</strong></p> <pre><code>&lt;%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage&lt;Data.User&gt;" %&gt; &lt;% using (Html.BeginForm()) {%&gt; &lt;%= Html.ValidationSummary(true) %&gt; &lt;fieldset&gt; &lt;legend&gt;Fields&lt;/legend&gt; &lt;div class="editor-label"&gt; &lt;%= Html.LabelFor(model =&gt; model.Id) %&gt; &lt;/div&gt; &lt;div class="editor-field"&gt; &lt;%= Html.TextBoxFor(model =&gt; model.Id) %&gt; &lt;%= Html.ValidationMessageFor(model =&gt; model.Id) %&gt; &lt;/div&gt; &lt;div class="editor-label"&gt; &lt;%= Html.LabelFor(model =&gt; model.UserName) %&gt; &lt;/div&gt; &lt;div class="editor-field"&gt; &lt;%= Html.TextBoxFor(model =&gt; model.UserName) %&gt; &lt;%= Html.ValidationMessageFor(model =&gt; model.UserName) %&gt; &lt;/div&gt; &lt;div class="editor-label"&gt; &lt;%= Html.LabelFor(model =&gt; model.Email) %&gt; &lt;/div&gt; &lt;div class="editor-field"&gt; &lt;%= Html.TextBoxFor(model =&gt; model.Email) %&gt; &lt;%= Html.ValidationMessageFor(model =&gt; model.Email) %&gt; public ActionResult EditUser(int id) { var usr = _UsrService.GerUserById(id).ToList&lt;User&gt;(); return View(usr); } </code></pre>
    singulars
    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