private void cboDepartment_TextChanged(object sender, EventArgs e) { DepartmentBO department = new DepartmentBO(); QuestionBO q = new QuestionBO(); var a = department.getDepartmentName(cboDepartment.Text); string b = "0"; foreach (var temp in a) { b = temp.DepartmentID.ToString(); } if (b != "0") { gridControl1.DataSource = q.GetDepartmentnameFromDepartmentID(Int32.Parse(b)); } if (b == "0") { gridControl1.DataSource = q.GetDepartmentALL(); } }