private void searchButton_Click(object sender, EventArgs e) { int outvalue; if (Int32.TryParse(searchTextBox.Text, out outvalue)) { studentDataGridView.DataSource = ob.SearchFromStudentInfoTable(searchTextBox.Text); } else { MessageBox.Show("Only Student ID & Dept ID!!!"); searchTextBox.ResetText(); } }