我有这个在我的模型,内容是国家的完整列表:设置DropDownListFor
public IList<LookupCountry> LookupCountry { get; set; };
public int SelectedCountry { get; set; }
的这个样子的
public class LookupCountry : ILookup
{
public virtual int Id { get; set; }
public virtual int Code { get; set; }
public virtual string FR { get; set; }
}
public interface ILookup
{
int Id { get; set; }
int Code { get; set; }
string FR { get; set; }
}
在视图中,我想展示该国列表和选定的值。
@Html.DropDownListFor(c => c.LookupCountry.Id,
new SelectList(Model.LookupCountry,
"Id",
"Value",
Model.SelectedCountry),
"-- Select Country --")
当我这样做,我有恩的错误,在c => c.LookupCountry.Id
的编号是不是在视图中可用。
有什么想法?
感谢,