i have populated one of my view with this viewmodel
public ActionResult AddStudent(int id)
{
var record = (from x in db.Registers
where (x.RegisterId == id)
select new StudentModel()
{
Batch = x.Batch,
ClassRoll = x.RoleNo,
Department = x.Department,
Name = x.StudentFullName
}).ToList();
return View(record);
}
these values are coming from database and persist on viewmodel to display but the problem is
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult AddStudent(StudentModel s)
{
Student stu = new Student();
s.LibraryCardNo = stu.LibraryCardNo;
s.Name = stu.Name;
s.Department = stu.Department;
s.Batch = stu.Batch;
s.ClassRoll = stu.RollNo;
db.Students.Add(stu);
ViewBag.Msg = "Record Inserted";
return View();
}
when this viewmodel is sent back to processing t
hese values are empty i don't know how to fix this thing.please help me

umair mohsinRank #3,092 · 463 reputationPosted Dec 17, 2018, 5:28 AM EST
Vincent Maverick DuranoRank #238 · 10.3K reputationPosted Dec 17, 2018, 1:55 PM EST