Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
3160
How to get DataItem for AddRecord?
posted

In the attached project I have a xamdatagrid with two combo box type controls on each row.  When the value of one of the controls changes, I want to update the value of the other.  For example, when the user uses the "Account number" control to select an account by account number, I want to update the "Account Name" control to refelect the selected account name.  Please see the code below in MainWindow.xaml.cs:

   private void SelectorTextBox_SelectionChanged(KeyValuePair<string, string> SelectedItem)
        {
            Trade t = (Trade)grid.ActiveDataItem;  // Fails here because ActiveDataItem is null if row has not been committed.
            t.ACCT_NO = Convert.ToInt32(SelectedItem.Key);
            t.ACCT_Name = SelectedItem.Value;
        }

The problem only occurs if the user changes a control on the Add row, in which case the Active Data Item is null.

 

Thanks,

 

Sam

 

 

XamGridEditorTest.zip
Parents Reply Children