public ActionResult BindEmp(int CompId, int Month, int Year) { objPayService = new PayrollService(); objPayItem = new PayrollItem(); List <PayrollItem> PayItem = new List <PayrollItem>(); List <EmployeeItem> lstEmp = new List <EmployeeItem>(); PayItem = objPayService.GetPayrollDetails1(Month, Year, CompId); if (PayItem.Count != 0) { objPayItem.lstPayroll = new List <PayrollItem>(); TempData["Msg"] = "EmployeeExists"; objPayItem.lstPayroll.AddRange(PayItem); ViewBag.MonthList = Month; ViewBag.YearList = Year; //lstEmp = objPayService.BindEmployee(CompId); //objPayItem.lstEmployee = new List<EmployeeItem>(); //objPayItem.lstEmployee.AddRange(lstEmp); } else { TempData["Msg"] = ""; if (CompId != 0) { lstEmp = objPayService.BindEmployee(CompId); objPayItem.lstEmployee = new List <EmployeeItem>(); objPayItem.lstEmployee.AddRange(lstEmp); } PayItem = objPayService.BindPayroll(CompId); objPayItem.lstPayroll = new List <PayrollItem>(); objPayItem.lstPayroll.AddRange(PayItem); ViewBag.MonthList = Month; ViewBag.YearList = Year; } return(PartialView("_List", objPayItem)); }