3,597 questions
Saving Dynamic Form Fields to Database with Fixed Values in MVC
kadir
60
Reputation points
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult Create(EgitimSeminerViewModel model)
{
if (ModelState.IsValid)
{
for (int i = 0; i < model.EgitimSeminerBilgiList.Count; i++)
{
TBL_EgitimSeminerBilgi item = new TBL_EgitimSeminerBilgi();
item.EgitimKonu = model.EgitimSeminerBilgiList[i].EgitimKonu;
item.EgitimKurum = model.EgitimSeminerBilgiList[i].EgitimKurum;
item.EgitimSuresi = model.EgitimSeminerBilgiList[i].EgitimSuresi;
db.TBL_EgitimSeminerBilgi.Add(item);
}
db.SaveChanges();
return RedirectToAction("Create"); // Or other redirection
}
return View(model);
}
Hello everyone, friends, my goal here is to record according to the number of incoming data, no problem until this part
but I also want to add the GeneralInfoid and value fields in the same table, so these fields will be fixed.
item.GenelBilgiid = 12; item.deger = false; no matter how many times the data is added
Developer technologies ASP.NET Other
Sign in to answer