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