//初始化界面呈现数据 private void GenerateViewDatas() { List <SelectListItem> selectListItems = new List <SelectListItem>(); //获取为父级的对象 var tems = _menuAppService.GetAllParentDtos(); foreach (var tem in tems) { selectListItems.Add(new SelectListItem(tem.Name, tem.Name));//将父级对象加入ViewData中 } ViewData["Parents"] = selectListItems; //功能类型 selectListItems = new List <SelectListItem>(); selectListItems.Add(new SelectListItem("导航菜单", "导航菜单")); selectListItems.Add(new SelectListItem("功能按钮", "功能按钮")); ViewData["MenuTypes"] = selectListItems; }