Note that there are some explanatory texts on larger screens.

plurals
  1. POASP MVC3 Error - There is no ViewData item of type 'IEnumerable<SelectListItem>' that has the key
    text
    copied!<p>I've researched this a bit and haven't found an answer that quite deals with a similar situation or MVC3. In the ViewModel I'm using I have a Lists of a separate model (<code>List&lt;AgentId&gt;</code> which is a list of the <code>AgentId</code> model). </p> <p>In the <code>Create</code> page for this controller, I need an input section for 5 items to be added to this list. However, before the page even load, I receive this error message: </p> <p><code>There is no ViewData item of type 'IEnumerable&lt;SelectListItem&gt;' that has the key 'BankListAgentId[0].StateCode'.</code></p> <p>Here is the ViewModel I am using: </p> <pre><code>public class BankListViewModel { public int ID { get; set; } public string ContentTypeID1 { get; set; } public string CreatedBy { get; set; } public string MANonresBizNY { get; set; } public string LastChangeOperator { get; set; } public Nullable&lt;System.DateTime&gt; LastChangeDate { get; set; } public List&lt;BankListAgentId&gt; BankListAgentId { get; set; } public List&lt;BankListStateCode&gt; BankListStateCode { get; set; } } </code></pre> <p>And here is the section of the view that's having the issues: </p> <pre><code>&lt;fieldset&gt; &lt;legend&gt;Stat(s) Fixed&lt;/legend&gt; &lt;table&gt; &lt;th&gt;State Code&lt;/th&gt; &lt;th&gt;Agent ID&lt;/th&gt; &lt;th&gt;&lt;/th&gt; &lt;tr&gt; &lt;td&gt; @Html.DropDownListFor(model =&gt; model.BankListAgentId[0].StateCode, (SelectList)ViewBag.StateCode, " ") &lt;/td&gt; &lt;td&gt; @Html.EditorFor(model =&gt; model.BankListAgentId[0].AgentId) @Html.ValidationMessageFor(model =&gt; model.BankListAgentId[0].AgentId) &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt; @Html.DropDownListFor(model =&gt; model.BankListAgentId[1].StateCode, (SelectList)ViewBag.StateCode, " ") &lt;/td&gt; &lt;td&gt; @Html.EditorFor(model =&gt; model.BankListAgentId[1].AgentId) @Html.ValidationMessageFor(model =&gt; model.BankListAgentId[1].AgentId) &lt;/td&gt; &lt;td id="plus2" class="more" onclick="MoreCompanies('3');"&gt;+&lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;/fieldset&gt; </code></pre>
 

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