I want to insert a record into database and display into gridview
but 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();
}
Object reference not set to an instance of an object.
list.empname = c.EmpName;
here i am getting error
plz help
me thanq.