Click here to Skip to main content
15,893,368 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
below is my code whenever I change value of cell value and then press enter it shows an exception whereas after editing the cell value when I click mouse button it works fine
The exception I get is An unhandled exception of type 'System.ArgumentOutOfRangeException' occurred in PresentationFramework.dll

and the it also goes into breakmode

C#
private void dgOrder_CellEditEnding(object sender, DataGridCellEditEndingEventArgs e)
        {
            DataGrid dc = (DataGrid)sender;
            DataGridRow row1 = e.Row;
            DataRowView row = (DataRowView)dc.SelectedItems[0];
            var value = e.EditingElement as TextBox;

            int row_index = ((DataGrid)sender).ItemContainerGenerator.IndexFromContainer(row1);

            ol.UpdateOrderLine(row[0].ToString(), "Qty", int.Parse(value.Text.ToString()));
            MessageBox.Show(row_index.ToString() + " " + row["PName"] + " " + e.Column.Header.ToString() + " " + value.Text.ToString() + " result: " + result);
            dgOrder.ItemsSource = ol.GetOrderLine().DefaultView;
        }


What I have tried:

when I remove this line dgOrder.ItemsSource = ol.GetOrderLine().DefaultView it works fine, values are updated in the database but datagrid is not updated at that moment
Posted

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