Does anyone know where is my code going wrong here? This piece of code work perfectly fine but I transferred the file to another computer, this error popped out when I compile the file.
private void ShowGeneratedSchedule(string sLocationName, string sAllocationDate)
{
//lstAllocation = db.allocations.Where(a => a.AllocationDate == sAllocationDate &&
// a.LocationName == sLocationName).ToList();
scheduleDGV.EditMode = DataGridViewEditMode.EditProgrammatically;
for (int i = 0; i < lstAllocation.Count; i++)
{
for (int j = 0; j < scheduleDGV.Rows.Count - 1; j++)
{
for (int k = 0; k < scheduleDGV.Columns.Count; k++)
{
if (scheduleDGV[0, j].Value.Equals(lstAllocation[i].LocationName) &&
scheduleDGV[1, j].Value.Equals(lstAllocation[i].StationName) &&
scheduleDGV.Columns[k].HeaderText.Equals(lstAllocation[i].AllocationTime.ToString()))
{
if (lstAllocation[i].EmployeeName != null)
{
scheduleDGV[k, j].Value = lstAllocation[i].EmployeeName;
}
}
}
}
}
//scheduleDGV.DataSource = lstEmployeeSlot;
}
The error is displayed when it reaches this line,
for (int i = 0; i < lstAllocation.Count; i++)
Does anyone know what’s wrong here? Is it possible that it is transferred into another computer?
lstAllocationis not initialized? What is it with the comment in the first line of the method? Why is that commented out? Without thatlstAllocationhas no content.