using (var dbCtx = new EmployeeEntities()) { //Mark entity as modified dbCtx.Entry(stud).State = System.Data.EntityState.Modified; dbCtx.SaveChanges(); }
private void Save() { EmployeeMast objEmp = new EmployeeMast(); objEmp.EmpName = txtName.Text.Trim(); objEmp.EmpAdd = txtAddress.Text.Trim(); // objEmp.EmpBDate = Convert.ToDateTime(txtBDay.Text.Trim()); objEmp.EmpDept = Convert.ToInt32(drpDepartment.SelectedValue); if (ViewState["EmpId"] == null) { obj.EmployeeMasts.AddObject(objEmp); obj.SaveChanges(); } else { objEmp.EmpId = 1; obj.Entry(objEmp).State = System.Data.EntityState.Modified; obj.SaveChanges(); } } if i am update record then write code this line. obj.Entry(objEmp).State = System.Data.EntityState.Modified; then "Entry" not set ..Error display.
obj.EmployeeMasts.Attach(objEmp);
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)