private void cmbBook_SelectedIndexChanged(object sender, EventArgs e) { var dc = new ClassSRMDataContext(Config.connection); int count = (cmbClass.Properties.DataSource as IList).Count; if (count > 0) { bsStudent.DataSource = (from tbl_Student in dc.tbl_Students where !dc.tbl_Quastions.Any(f => f.StudentId == tbl_Student.Id && f.Book == cmbBook.Text) && tbl_Student.StuClassId == (int)cmbClass.EditValue select new { tbl_Student.Id, tbl_Student.StuName, tbl_Student.StuLName, tbl_Student.StuFName }); if (gridView1.RowCount == 0) { dc.DeleteAllQuastion((int)cmbClass.EditValue, cmbBook.Text); cmbBook_SelectedIndexChanged(null, null); } } }