我的下拉列表在创建视图中运行良好。但在编辑视图中,此下拉列表未加载对象原始值

My dropdown list which is working fine in create view. but in edit view this dropdown did not load object original values

这是我的下拉列表,在创建视图中运行良好。但在编辑视图中,此下拉列表未加载对象原始值

@Html.DropDownListFor(model => model.FundingSource, new List<SelectListItem>
                {new SelectListItem {Text = "ADP", Value = "ADP"},
                 new SelectListItem {Text = "CG", Value = "CG"},
                 new SelectListItem {Text = "ADP(D)", Value = ADP(D)"},                   
                 new SelectListItem {Text = "Others", Value = "Others"}                         
               }, --Select--,new {@class="form-control"})

我认为这就是您所需要的。请注意,在加载视图之前,您应该在操作中填充模型。

@Html.DropDownListFor(model => model.FundingSource, new SelectList(new List<SelectListItem>
            {new SelectListItem {Text = "ADP", Value = "ADP"},
             new SelectListItem {Text = "CG", Value = "CG"},
             new SelectListItem {Text = "ADP(D)", Value = "ADP(D)"},
             new SelectListItem {Text = "Others", Value = "Others"}
           }, "Text", "Value", Model.FundingSource), "--Select--",new {@class="form-control"})