ASP NET MVC 4 collection is null on post

后端 未结 3 802
时光取名叫无心
时光取名叫无心 2020-12-22 13:06

I read most of Google :-), but I can\'t proceed. The collection on my object is and stays null on post, whatever I do.

My Model:

public class Artic         


        
3条回答
  •  無奈伤痛
    2020-12-22 13:58

    Thank you guys.

    The problem was, that I did the testing with the script from the Fiddle. In this code

    Model.ArtikelListe[i].MitAnzahl
    

    was always true.

    In case it is not true, the value "Anzahl" was not bound to a control containing a value (but just a label).

    @Html.LabelFor(x => x.ArtikelListe[i].Anzahl)
    

    As soon as I inserted a hidden field within that scope and bound the "Anzahl" value to it, the post returned with all the data I expected.

    Thanks anyway. I learned a lot!

提交回复
热议问题