private void btnShow_Click(object sender, RoutedEventArgs e) { try { string SellerName = txtOwnerName.Text; List <Property> viewProperty = propertyBL.GetAllPropertyByOwnerBL(SellerName); if (viewProperty != null && viewProperty.Count > 0) { dgViewProperties.DataContext = viewProperty; } else { MessageBox.Show("No record found"); } } catch (EasyHousingSolutionException ex) { MessageBox.Show("Error: " + ex); } catch (Exception ex) { MessageBox.Show("Error: " + ex); } }