(资料图片仅供参考)
导读
1、直接赋值:@Html.DropDownListFor(o => o.ParentId, ViewBag.root as IEnumerable,"默认值")2、在初始化时赋值:View层:@Html.DropDownListFor(o => o.ParentId, ViewBag.root as IEnumerable)Controller层:var parent = _dictionaryService.Where(o => o.IsDeleted == false && o.DisLevel == 1).ToList().Select(o => new SelectListItem(){Text = o.Name.ToString(),Value = o.Id.ToString()});ViewBag.root = parent;DictionaryViewModel viewModel = new DictionaryViewModel();viewModel.ParentId = id;string disOrder = "";disOrder = LoadDetailOrderNumber(id);viewModel.DisOrder = disOrder.AsInt();return View(viewModel);。
本文到此分享完毕,希望对大家有所帮助。
免责声明:免责声明:本文由用户上传,如有侵权请联系删除!