// // GET: /Admin/SystemSetting/Edit/5 public ActionResult Edit(string key) { SystemSetting systemSetting = _systemSettingService.GetSystemSetting(key); if (systemSetting == null) { ErrorNotification("Không tìm thấy trang tĩnh nào thỏa mãn"); return(RedirectToAction("Index")); } Title = "Chỉnh sửa SystemSetting"; ViewData["ToolbarTitle"] = Title; SystemSettingModel model = systemSetting.ToCreateModel(); if (model.Type != 1 && model.Type != 2) { if (model.Options != null) { List <object> myObj = new List <object>(); string[] options = model.Options.Trim().Split('|'); foreach (var s in options) { string[] strOption = s.Trim().Split('='); myObj.Add(new { Id = strOption[0], Name = strOption[1] }); } model.ListOptions = new SelectList(myObj, "Id", "Name", model.Value); } } if (model.Type == 3) { string[] arrValue = systemSetting.Value.Split(','); List <string> list = new List <string>(); for (int i = 0; i < arrValue.Length; i++) { list.Add(arrValue[i]); } model.ListSelected = list; } var statuses = from SystemSettingcsEnum s in Enum.GetValues(typeof(SystemSettingcsEnum)) select new { ID = (int)s, Name = s.ToString() }; model.SystemSettingType = new SelectList(statuses, "Id", "Name", model.Type); //JavaScriptSerializer serializer = new JavaScriptSerializer(); //List<SelectListItem> dataObj = serializer.Deserialize<List<SelectListItem>>(model.Options); //model.ListOptions = new SelectList(dataObj, "Value", "Text", model.Value); return(View(model)); }