Note that there are some explanatory texts on larger screens.

plurals
  1. POView not binding correcty with the model
    primarykey
    data
    text
    <p>I can figure out why it's not binding. So I have a form where a ListBox is in a partial view which I reload everytime I click on a checkbox to fill the listbox. </p> <p>The code of my ModelView for the form is :</p> <pre><code> &lt;div class="row-fluid"&gt; &lt;div class="span3"&gt; &lt;label&gt;Fonction(s):&lt;/label&gt; &lt;/div&gt; &lt;div class="span9" id="ListeFonction"&gt; @Html.Partial("ListerFonction", Model) &lt;/div&gt; &lt;/div&gt; &lt;div class="row-fluid"&gt; &lt;div class="span5 offset3"&gt; &lt;div class="fonctions_container"&gt; @foreach (extranetClient.Models.Classes.FonctionContact fonction in ViewBag.Fonctions) { string coche = ""; if ((@Model.ListeFonctions).Any(c =&gt; c.IdFonction == fonction.IdFonction)) { coche = "checked"; } &lt;input type="checkbox" @coche class="checkbox" value="@fonction.IdFonction" /&gt;@fonction.LibelleFonction &lt;br /&gt; } &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <p>So as you can see, I render a partial view just after the "Email" Textbox. The code for it is :</p> <pre><code>@Html.LabelFor(contact =&gt; contact.SelectedFonctionIds, "ListeFonctions") @Html.ListBoxFor(contact =&gt; contact.SelectedFonctionIds, new MultiSelectList(Model.ListeFonctions, "IdFonction", "LibelleFonction"), new { disabled = "disabled") </code></pre> <p>The model associated to that view looks like that: </p> <pre><code> private List&lt;int&gt; _selectedFonctionIds; public List&lt;int&gt; SelectedFonctionIds { get { return _selectedFonctionIds ?? new List&lt;int&gt;(); } set { _selectedFonctionIds = value; } } public List&lt;FonctionContact&gt; ListeFonctions = new List&lt;FonctionContact&gt;(); public MultiSelectList ListeFonctionsSelectList { get { return new MultiSelectList( ListeFonctions, "IdFonction", // dataValueField "LibelleFonction" // dataTextField ); } } public Contact() { } public Contact( List&lt;FonctionContact&gt; listeFonctions, List&lt;int&gt; selectedFonctionIds) { this.ListeFonctions = listeFonctions; this.SelectedFonctionIds = selectedFonctionIds; } public Contact(int idContact, string nom, string prenom, string email, string telephoneFixe, string telephonePort) { this.IdContact = idContact; this.Nom = nom; this.Prenom = prenom; this.Email = email; this.TelephoneFixe = telephoneFixe; this.TelephonePort = telephonePort; } public Contact(int idContact, string nom, string prenom, List&lt;int&gt; selectedFonctionIds, List&lt;FonctionContact&gt; listeFonctions, string email, string telephoneFixe, string telephonePort) { this.IdContact = idContact; this.Nom = nom; this.Prenom = prenom; this.SelectedFonctionIds = selectedFonctionIds; this.ListeFonctions = listeFonctions; this.Email = email; this.TelephoneFixe = telephoneFixe; this.TelephonePort = telephonePort; } </code></pre> <p>But the ListBox of the partial view is not binding with the model. I get well the other informations but not these in the listbox. Somebody has an idea ?</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.
 

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