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
1025
How to move nested DataRecord up one position under parent record.
posted

How can move a DataRecord up one position (current index - 1) under a parent record? I have the following method that move records up to the next parent, but what I really want is to just move the record up under it's current parent if it has other sibling records before it.

private void MoveUp(object sender, RoutedEventArgs e)

{

if (theDataGrid.SelectedItems.Records.Count > 0)

{

DataRecord dr = theDataGrid.SelectedItems.Records[0] as DataRecord;

if (dr != null)

{

if (dr.ParentDataRecord.ParentDataRecord != null)

{

theDataGrid.ExecuteCommand(
DataPresenterCommands.StartEditMode);

dr.Cells["parent_id"].Value = dr.ParentDataRecord.ParentDataRecord.Cells["product_structure_id"].Value;

theDataGrid.ExecuteCommand(DataPresenterCommands.EndEditModeAndAcceptChanges);

dr.Update();

}

}

}

}