2016-07-29 5 views
0

Ich frage mich, ob jemand weiß, warum meine Dropdown-Liste nicht ändert und den neuen Wert auf den Controller zurückstellen, wenn ich die Option in der Auswahlliste ändern. Die Auswahlliste befindet sich in einem Forloop, das mehrere Elemente mit mehreren Auswahllisten anzeigt, so dass der Benutzer das ausgewählte Element in ein neues Element ändern kann.DropDownListFür den ausgewählten Wert nicht zu ändern, wenn ich einen neuen Wert auswähle

@for (int i = 0; i < Model.PoItemsList.Count; i++) 
{ 
    net += Convert.ToDecimal(Model.PoItemsList[i].Net); 
    vat += Convert.ToDecimal(Model.PoItemsList[i].Vat); 
    gross += Convert.ToDecimal(Model.PoItemsList[i].Gross); 
    <tr> 
     <td> 
      @Html.HiddenFor(m => m.PoItemsList[i].Id) 
      @Html.HiddenFor(m => m.PoItemsList[i].NCodeId) 
      @Html.TextBoxFor(m => m.PoItemsList[i].ItemRef, new { @class = "form-control" }) 
     </td> 
     <td> 
      @Html.TextBoxFor(m => m.PoItemsList[i].Description, new { @class = "form-control", @style = "width: 200px;" }) 
     </td> 
     <td> 
      @*@Html.DropDownListFor(m => m.PoItemsList[i].NCodeId, Model.NominalCodeList, new { @class = "form-control", @id = "ncode" })*@ 
      @Html.DropDownListFor(m => m.PoItemsList[i].NCodeId, new SelectList(Model.NominalCodeList, "Value", "Text", Model.PoItemsList[i].NCodeId), new { @class = "form-control"}) 
     </td> 
     <td> 
      @Html.TextBoxFor(m => m.PoItemsList[i].CostPerItem, new { @class = "form-control", @Value = Convert.ToDecimal(Model.PoItemsList[i].CostPerItem) }) 
     </td> 

     <td> 
      @Html.TextBoxFor(m => m.PoItemsList[i].Quantity, new { @class = "form-control", @style = "width: 50px;" }) 
     </td> 
     <td> 
      @Html.TextBoxFor(m => m.PoItemsList[i].Net, new { @class = "form-control cpd-align-right", @Value = Convert.ToDecimal(Model.PoItemsList[i].Net) }) 
     </td> 
     <td> 
      @Html.TextBoxFor(m => m.PoItemsList[i].Vat, new { @class = "form-control cpd-align-right", @Value = Convert.ToDecimal(Model.PoItemsList[i].Vat) }) 
     </td> 
     <td> 
      @Html.TextBoxFor(m => m.PoItemsList[i].Gross, new { @class = "form-control cpd-align-right", @Value = Convert.ToDecimal(Model.PoItemsList[i].Gross) }) 
     </td> 
     <td> 
      @Html.CheckBoxFor(m => m.ManualEntry, new {@class = "form-control"}) 
     </td>       
     <td> 
      <input type="button" class="btn btn-danger centre" value="X" onclick="DeleteItemAndSave(@Model.PoItemsList[i].Id)" /> 
     </td> 
    </tr> 
} 
+0

Werden andere Eigenschaften in der PoItemsList richtig ausgefüllt, wenn Sie einen Post zurück machen? – Cizaphil

+0

Ja, wenn ich etwas anderes in der Poitemlist eg.description ändere, werden die Änderungen zurück auf die Controller-Feineinstellung gebucht. – user3481085

+0

Folgen @Ade Stringer Antwort und sehen, was passiert – Cizaphil

Antwort

1

Sie haben eine Liste @Html.HiddenFor(m => m.PoItemsList[i].NCodeId) und einen Rückgang machte sich an dem gleichen Punkt gebunden ist; Entfernen Sie die versteckte Eingabe und Ihr Code sollte gut funktionieren.

+0

Sie sind ein Lebensretter! – user3481085

Verwandte Themen