title: TextBlock in c# get an empty value in RowEditEnding in datagrid
body: <p>I use RowEditEnding event in datagrid to get updated row and update my database in return </p>
  
  <pre><code>    private void OnUpdateOrInsertItem(object sender,DataGridRowEditEndingEventArgs e)
      {
          DataGridRow row1 = e.Row;
  
          int row_index = ((DataGrid)sender).ItemContainerGenerator.IndexFromContainer(row1);
          int numberOfColumns = ((DataGrid)sender).Columns.Count;
          DataGridCell RowColumn = ((DataGrid)sender).Columns[1].GetCellContent(row1).Parent as DataGridCell;
          string CellValue = ((TextBlock)RowColumn.Content).Text;
          MessageBox.Show(CellValue);
      }
  </code></pre>
  
  <p>but when I change cell which I print it in messageBox ,it returns an empty value on messageBox.
  I think the problem related to threads 
  this is my xml code </p>
  
  <pre><code>&lt;Grid&gt;
      &lt;DataGrid x:Name="datagrid1" AutoGenerateColumns="true" HorizontalAlignment="Left" Margin="0,55,0,0" VerticalAlignment="Top" Height="248" Width="672"  RowEditEnding="OnUpdateOrInsertItem" PreviewKeyDown="OnDeleteItem"/&gt;
      &lt;Button Content="Show Database" HorizontalAlignment="Left" Margin="54,10,0,0" VerticalAlignment="Top" Width="98" RenderTransformOrigin="-0.193,-13.506" Height="29" Click="Button_Click_1"/&gt;
      &lt;ComboBox x:Name="comboBox1" SelectedIndex="0" HorizontalAlignment="Left" Margin="469,17,0,0" VerticalAlignment="Top" Width="120" Loaded="ComboBox_Loaded"
      SelectionChanged="ComboBox_SelectionChanged"/&gt;
  &lt;/Grid&gt;
  </code></pre>
  
  <p>how can I solve this problem or if there another way to get updated row in RowEditEnding event ?</p>