MVC binding to model with list property ignores other properties

后端 未结 3 879
别跟我提以往
别跟我提以往 2020-12-08 07:20

I have a basic ViewModel with a property that is a List of complex types. When binding, I seem to be stuck with getting either the list of values, OR the other model propert

3条回答
  •  时光说笑
    2020-12-08 07:42

    Just my 2 cents but something worth noting with this issue - the data member in the View Model must be defined as a public property for the postback model binding to work. I had a very similar problem to the above but used a public data member in my View Model. The same HTML is generated as shown above and all looks well but the model binder threw back an empty collection. Worth watching for...

提交回复
热议问题