ASP.NET MVC: Binding a Complex Type to a Select

前端 未结 3 1555
北恋
北恋 2020-12-28 16:30

I am trying to work out if there is built-in support for binding complex types to form elements.

To use a common hypothetical situation: I have a Product entity that

3条回答
  •  太阳男子
    2020-12-28 17:11

    The closest I think that it will come is overriding the ToString() method in the class to output meaningful information to the DropDownList - but not much else.

    You may be able to bind the IEnumerable collection to a DropDownList and then retrieving its SelectedItem when the form is submitted - that is the cheapest way I can think of.

提交回复
热议问题