//for shift protected void chkCtrlShift_CheckedChanged(object sender, EventArgs e) { foreach (GridViewRow row in grid_Shift.Rows) { CheckBox ck = ((CheckBox)row.FindControl("chkCtrlShift")); Shift _Shift = new Shift(); _Shift.ShiftID = Convert.ToByte(row.Cells[1].Text); _Shift.ShiftName = row.Cells[2].Text; if (ck.Checked) { if (SelectedShifts.Where(aa => aa.ShiftID == _Shift.ShiftID).Count() == 0) { SelectedShifts.Add(_Shift); } } else { if (SelectedShifts.Where(aa => aa.ShiftID == _Shift.ShiftID).Count() > 0) { var shift = SelectedShifts.Where(aa => aa.ShiftID == _Shift.ShiftID).First(); SelectedShifts.Remove(shift); } } } }