Пример #1
0
        public ActionResult Index(SampleVM data)
        {
            // 寫入資料
            if (ModelState.IsValid)
            {
                TempData["IndexSaveMsg"] = "新增" + data.Name + "成功";
                return RedirectToAction("IndexResult");
            }

            return View(data);
        }
Пример #2
0
        public ActionResult Show()
        {
            var data = new SampleVM()
            {
                Title = "CTO",
                Name = "Will",
                Level = 5,
                Gender = GenderEnum.中性 | GenderEnum.男性
            };

            return View(data);
        }
Пример #3
0
        public ActionResult Index(SampleVM data)
        {
            //ModelState.Clear();

            var dt = new SampleVM() { Name = "Will", Title = "CTO" };

            ViewData["Name"] = "John";

            //var list = new List<SelectListItem>();

            //list.Add(new SelectListItem() { Text = "進階班", Value = "3" });
            //list.Add(new SelectListItem() { Text = "中級班", Value = "2" });
            //list.Add(new SelectListItem() { Text = "初階班", Value = "1" });

            //ViewData["LevelOptions"] = new SelectList(list, "Value", "Text", 1);


            ViewData["LevelOptions"] = new SelectList(db.Occupation.ToList(),
                "OccupationId", "OccupationName", 1);

            return View(dt);
        }