V
V
VovchikKim2019-04-24 18:44:37
ASP.NET
VovchikKim, 2019-04-24 18:44:37

How to fix insert,upodate,delete error in asp.net mvc?

5cc084629fa0d256489285.pngI created a controller using the Entity framework, it gives an error. I so understood a problem in the Base? or the code generated by the entity framework is not working?

// GET: Производство/Create
        public ActionResult Create()
        {
            ViewBag.Бюджет = new SelectList(db.Бюджет, "ID", "ID");
            ViewBag.Продукция = new SelectList(db.Готовая_продукция, "ID", "Наименование");
            ViewBag.Сотрудник = new SelectList(db.Сотрудники, "ID", "Наименование");
            return View();
        }
 
        // POST: Производство/Create
        // To protect from overposting attacks, please enable the specific properties you want to bind to, for 
        // more details see https://go.microsoft.com/fwlink/?LinkId=317598.
        [HttpPost]
        [ValidateAntiForgeryToken]
        public ActionResult Create([Bind(Include = "ID,Продукция,Количество,Дата,Сотрудник,Бюджет")] Производство производство)
        {
            if (ModelState.IsValid)
            {
                db.Производство.Add(производство);
                db.SaveChanges();
                return RedirectToAction("Index");
            }
 
            ViewBag.Бюджет = new SelectList(db.Бюджет, "ID", "ID", производство.Бюджет);
            ViewBag.Продукция = new SelectList(db.Готовая_продукция, "ID", "Наименование", производство.Продукция);
            ViewBag.Сотрудник = new SelectList(db.Сотрудники, "ID", "Наименование", производство.Сотрудник);
            return View(производство);
        }

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vladimir Kim, 2019-04-25
@ETOZHEKIM

Cool variable name

ViewBag.Бюджет
ViewBag.Продукция
db.Производство
производство.Бюджет

Why are you surprised that nothing works? (I call it the Amanism Theory)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question