Click here to Skip to main content
15,881,841 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hello I am trying to create a details DataGrid for a Master ID
However when I enter a new ID and try to edit the details DataGrid the new details record disappears from the DataGrid but is stored in the DataTable and I can see it when I reload the project.

XAML
I am using CollectionViewSource and they display the Master Detail scenario just fine but when it comes to updating.
Here I create a new record where the User inputs new ID and new Details for the ID
This works fine.
C#
button click
    {
    CollectionViewSource vs = (CollectionViewSource)FindResource("CVSVouchers);
                    ObjectDataProvider odp = (ObjectDataProvider)FindResource("Vouchers");
                    DataView dv = (DataView)odp.Data;
                    dv.AddNew();           
                    vs.View.MoveCurrentToLast();
    
    }

and I handle the Datagrids Row EditEnding
C#
Datagrid RowEditEnding
{
            
                DataGridRow gridrow = e.Row;
                DataRowView drv = gridrow.Item as DataRowView;
                DataSet.ExpensesRow ExpRow = drv.Row as DataSet.ExpensesRow;
                actExpRow.VoucherSN = float.Parse(this.txtID.Text);

}

then the record disappears from the DataGrid but is saved in the DateTable.
Posted
Updated 31-Oct-11 9:14am
v7
Comments
Mehdi Gholam 31-Oct-11 12:15pm    
EDIT -> removed extra formatting
Sergey Alexandrovich Kryukov 31-Oct-11 12:33pm    
What, no source code? Who can understand where did you screw up without looking at your code? Try to create just a code sample, as simple as possible, without unrelated detail, don't post your "real" code. But the sample should manifest the problem.
--SA
conniekigg 31-Oct-11 14:52pm    
posted code

1 solution

Have a look at:
WPF DataGrid Practical Examples[^]

Best regards
Espen Harlinn
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900