datagrid and roweditending

Mar 11, 2009 at 9:16 PM
The below is my row edit ending function and the call to refresh the items in my grid after the edit.
When I use the dispatcher to call the refresh function, the error I see is:  'Refresh' is not allowed during an AddNew or EditItem transaction.

However if I refresh the grid manually as in user based, it refreshes fine.
How do you refresh the data after a rowedit?

    private object fillPRSList(object item)

            //LastCat = (string)category;
               prss = sdc.GetScheduleByCategory(LastCat);
            foreach (ProductReplacementSchedule prs1 in prss)

            //prs = new ProductReplacementSchedule();
            //prs.PrsID = 0;
            if (dataGrid1.ItemsSource == null)
                dataGrid1.ItemsSource = prsl;

            return null;

        private void dataGrid1_RowEditEnding(object sender, Microsoft.Windows.Controls.DataGridRowEditEndingEventArgs e)
            DataGridRow dr;
            if (e.EditAction == Microsoft.Windows.Controls.DataGridEditAction.Commit)
                dr = e.Row;
                prs = (ProductReplacementSchedule)dr.Item;
                if (prs.ChangedMachineName == null)
                    prs.ChangedMachineName = "server";
                if (prs.ChangedType == null)
                    prs.ChangedType = "I";
                if (prs.ChangedDate == null)
                    prs.ChangedDate = DateTime.Now;

                if (prs.PrsID == 0)
                    sdc.SaveChange(prs, "add");
                    sdc.SaveChange(prs, "update");
            //    Dispatcher.Invoke(new DispatcherOperationCallback(fillPRSList), DispatcherPriority.ApplicationIdle, dataGrid1);
//                fillPRSList(LastCat);
Mar 11, 2009 at 9:54 PM
Dispatcher.Invoke is a sync operation. Hence it executes before RowEditEnding returns and hence the problem. Try using Dispatcher.BeginInvoke instead (which is a async operation).
Dec 1, 2009 at 11:30 AM
Edited Dec 14, 2009 at 12:28 AM