hey guys,am working on an online admission project in mvc3 web apllication.
i have created a class of students and use an inerface as the middle man between the web apllication and my domain to save my records perfectly.i have used a view to present the form to the users and save the record into the database.The saving aspect works perfectly.
But what i want to accomplish is surposing the student want 2 cahange some information after saving,i want the records to be overwritten and not resaved in the database.
so i want to create an overloaded version of my view to accomplish that.
I tried it and i got an error that says that it cannot perform or bind a null reference.
Then i realise the error is correct becos the record has to be saved first before the student can edit.
however i cant seem to edit find a way around editing the record. any help will be appreciated cos am stock..here is my code below.
public ViewResult Registration(int id)
{
Student student = studentrepository.Student.FirstOrDefault(p => p.ID == id);
return View(student);
}
[HttpPost]
public ActionResult Registration(Student student)
{
if (ModelState.IsValid)
{
studentrepository.Save(student);
}
return View(student);
}