I want to insert a record into database and display into gridviewbut i am getting error protected void btnsubmit_Click(object sender, EventArgs e) { cmp c = new cmp(); c.EmpName = txtempname.ToString(); c.jobid = Convert.ToInt32(txtjobid.Text); c.managerid = Convert.ToInt32(txtmanagerid.Text); c.salary = Convert.ToInt32(txtsalary.Text); c.hiredate = Convert.ToDateTime(txthiredate.Text); Employee a = new Employee(); a.insertEmployeeData(c); } in DAl public void insertEmployeeData(cmp c) { CompanyDataContext db = new CompanyDataContext(); var list = db.Employees.Where(p => p.empid == c.Employeeid).FirstOrDefault(); list.empname = c.EmpName; list.jobid = c.jobid; list.hiredate = c.hiredate; list.salary = c.salary; list.managerid = c.managerid; db.Employees.InsertOnSubmit(list); db.SubmitChanges(); }