我期望在.NET MVC中實現它,但試圖找出如何實際執行它。目前在我的ViewModel,我有(例如):從ViewModel在視圖上創建自動生成的DropDownList
public class GroupPolicyViewModel
{
public int PolicyId { get; set; }
public int HistoryId{ get; set; }
public SelectList ProductList { get; set; } // tried this
public List<Product> ProductList1 { get; set; } // tried this
}
每當我嘗試並自動生成我查看來自該視圖模型的產品列表被忽略。有沒有辦法從ViewModel中自動生成一個DropDownList?
這可能會有所幫助: http://stackoverflow.com/questions/6663615/creating-a-dropdownlist-from-your-controller-or-view-model – Srinivas
不幸的是,這仍然意味着我必須在View中手動創建DropDownListFor。有沒有辦法解決? –