Whenever i click on link to update the data and insert new data the last field is embed with first field and itself is null, i cannot understand what the problem is that, sample code is given below
Action method Update:
public ActionResult Update(int id)
{
StudentEntities cx = new StudentEntities();
var q = cx.Infoes.Find(id);
return View(q);
}
View Update :
Update
Method update:
View Update :
@{
Layout = null;
}
Method update:
[HttpPost]
public ActionResult update()
{
int Id = int.Parse(Request["ID"]);
string Name = Request["Name"];
int Age = int.Parse(Request["Age"]);
string Address = Request["Address"];
string Interest = Request["Interest"];
StudentEntities cx = new StudentEntities();
var q = cx.Infoes.Find(Id);
q.Name = Name;
q.Age = Age;
q.Address = Address;
q.Interest = Interest;
cx.SaveChanges();
var l = cx.Infoes.ToList();
return View("Index", l);
}
Replies
Know the answer? Post it — somebody with the same question will find it here.