title: RowEditEnding and DataGrid update
body: <p>I have WPF <code>dataGrid</code> that; when I am updating my Database using <code>RowEditEnding</code> event it does not function properly.</p>
  <ol>
  <li>I enter new value, in the code I assign ID and when I'm back to Grid I do not see my ID but only value I typed. (if I close application, data are lost).</li>
  <li>When I double click on <code>datagrid</code> again and leave row everything works as it should have in the first place, data get updated and saved in DB.</li>
  </ol>
  <p>Am I using the right method?</p>
  <p>Here is my code:</p>
  <pre><code>&lt;Window.Resources&gt;
      &lt;local:ManageOrdersDataSet x:Key=&quot;manageOrdersDataSet&quot;/&gt;
      &lt;CollectionViewSource x:Key=&quot;customerViewSource&quot;
      Source=&quot;{Binding Customer, Source={StaticResource manageOrdersDataSet}}&quot;/&gt;
  &lt;/Window.Resources&gt;
  
  &lt;Grid DataContext=&quot;{StaticResource customerViewSource}&quot;&gt;
      &lt;DataGrid x:Name=&quot;customerDataGrid&quot;
                RowDetailsVisibilityMode=&quot;VisibleWhenSelected&quot;
                Margin=&quot;0,0,-0.2,0.4&quot; ItemsSource=&quot;{Binding}&quot;
                EnableRowVirtualization=&quot;True&quot; AutoGenerateColumns=&quot;False&quot;
                RowEditEnding=&quot;customerDataGrid_RowEditEnding&quot;&gt;
          &lt;DataGrid.Columns&gt;
              &lt;DataGridTextColumn x:Name=&quot;iDColumn&quot; Width=&quot;10&quot; Header=&quot;ID&quot;
                                  Binding=&quot;{Binding ID,  Mode=TwoWay,
                                  NotifyOnTargetUpdated=True,
                                  NotifyOnSourceUpdated=True,
                                  UpdateSourceTrigger=PropertyChanged}&quot;/&gt;
              &lt;DataGridTextColumn x:Name=&quot;nameColumn&quot; Width=&quot;*&quot; Header=&quot;Name&quot;
                                  Binding=&quot;{Binding Name, Mode=TwoWay,
                                  NotifyOnTargetUpdated=True,
                                  NotifyOnSourceUpdated=True,
                                  UpdateSourceTrigger=PropertyChanged}&quot;/&gt;
              &lt;DataGridTextColumn x:Name=&quot;addressColumn&quot; Width=&quot;*&quot; Header=&quot;Address&quot;
                                  Binding=&quot;{Binding Address, Mode=TwoWay,
                                  NotifyOnTargetUpdated=True,
                                  NotifyOnSourceUpdated=True,
                                  UpdateSourceTrigger=PropertyChanged}&quot;/&gt;
          &lt;/DataGrid.Columns&gt;
      &lt;/DataGrid&gt;
  &lt;/Grid&gt;
  </code></pre>
  <pre><code>OrderManager.ManageOrdersDataSet manageOrdersDataSet;
  OrderManager.ManageOrdersDataSetTableAdapters.CustomerTableAdapter
  manageOrdersDataSetCustomerTableAdapter;
  System.Windows.Data.CollectionViewSource customerViewSource;
  
  private void Window_Loaded(object sender, RoutedEventArgs e)
  {
      manageOrdersDataSet = ((OrderManager.ManageOrdersDataSet)
          (this.FindResource(&quot;manageOrdersDataSet&quot;)));
      // Load data into the table Customer.
      // You can modify this code as needed.
      manageOrdersDataSetCustomerTableAdapter = new
              OrderManager.ManageOrdersDataSetTableAdapters.CustomerTableAdapter();
      manageOrdersDataSetCustomerTableAdapter.Fill(
          manageOrdersDataSet.Customer);
      customerViewSource = ((System.Windows.Data.CollectionViewSource)
          (this.FindResource(&quot;customerViewSource&quot;)));
      customerViewSource.View.MoveCurrentToFirst();
  }
  
  private void customerDataGrid_RowEditEnding(object sender,
      DataGridRowEditEndingEventArgs e)
  {
      if (rowView != null)
      {
          ManageOrdersDataSet.CustomerRow row = rowView.Row
              as ManageOrdersDataSet.CustomerRow;
          if (row.IsNull(&quot;Name&quot;))
          {
              row[&quot;Name&quot;] = &quot;Defailt&quot;;
          }
          if (row.IsNull(&quot;Address&quot;))
          {
              row[&quot;Address&quot;] = &quot;Address Def&quot;;
          }
          if (row.IsNull(&quot;ID&quot;))
          {
              row[&quot;ID&quot;] = Guid.NewGuid();
          }
          this.manageOrdersDataSetCustomerTableAdapter.Update(row);
      }
  }
  </code></pre>