我的视图模型
public class MyTest
{
public string CountryId {get; set;}
public IEnumerable<SelectListItem> Countries {get; set;}
}
我的观点
@Model MyTest
@{
ViewBag._SelectList = MyTest.Countries;
//I want to call the partial view by
Html.Partial("_Dropdownlist"); //and specify the property x => x.CountryId
}
我正在创建一个局部视图,可用于所有下拉列表 _Dropdownlist.cshtml
@Html.DropDownListFor(<I need to use the property here>, ViewBag._SelectList)
如何将 lambda 表达式传递x => x.CountryId
给局部视图,以便可以跨多个视图重用 DropDownList.cshtml。
PS:我不想用Html.DropDownList
谢谢