private void searchButton_Click(object sender, RoutedEventArgs e) { if (IsTextAllowed(txtSearch.Text)) { int billNo = int.Parse(txtSearch.Text); { DataTable dt = billData.Search(billNo); dgvBills.ItemsSource = dt.DefaultView; } } else { MessageBox.Show("Enter Valid Bill Number!"); } }