Answer the question
In order to leave comments, you need to log in
How to fix insert,upodate,delete error in asp.net mvc?
I 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
Cool variable name
ViewBag.Бюджет
ViewBag.Продукция
db.Производство
производство.Бюджет
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question