This is a migrated thread and some comments may be shown as answers.

Object referecnce @ GridViewDataControl.CommitCurrentEdit

6 Answers 162 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Gautham
Top achievements
Rank 1
Gautham asked on 31 Oct 2011, 06:35 PM
I'm getting null ref error when i move from one cell to another in a rad grid view. This started happening once i move from version from 2011.1.419.35 to 2011.2.920.40.

Steps to reproduce

Create a grid so that columns so that all columns are not visible.
Bind the a column to an int/decimal value (<telerik:GridViewDataColumn DataMemberBinding="{Binding Path=OrderUnits, Mode=TwoWay}" UniqueName="QuantityColumn" Header="Quantity" />)
enter edit mode in this column
scroll to the end of the grid view so that this column is out of view
scroll back to original location
tab out of edit.

Version - 2011.2.920.40
WPF4



Stack trace below.

   at Telerik.Windows.Controls.GridView.GridViewDataControl.RaiseDataErrorEvent(DataErrorEventArgs args)
   at Telerik.Windows.Controls.GridView.GridViewDataControl.CommitCurrentEdit(GridViewRow gridViewRow)
   at Telerik.Windows.Controls.GridView.GridViewDataControl.PerformRowEditEnded(GridViewCell currentCell)
   at Telerik.Windows.Controls.GridView.GridViewDataControl.CommitCellEdit(GridViewCell currentCell, Boolean isLeavingRow)
   at Telerik.Windows.Controls.GridView.GridViewDataControl.CommitEdit()
   at Telerik.Windows.Controls.GridView.GridViewDataControl.OnCommitEditCommand(Object sender, ExecutedRoutedEventArgs e)
   at System.Windows.Input.CommandBinding.OnExecuted(Object sender, ExecutedRoutedEventArgs e)
   at System.Windows.Input.CommandManager.ExecuteCommandBinding(Object sender, ExecutedRoutedEventArgs e, CommandBinding commandBinding)
   at System.Windows.Input.CommandManager.FindCommandBinding(CommandBindingCollection commandBindings, Object sender, RoutedEventArgs e, ICommand command, Boolean execute)
   at System.Windows.Input.CommandManager.FindCommandBinding(Object sender, RoutedEventArgs e, ICommand command, Boolean execute)
   at System.Windows.Input.CommandManager.OnExecuted(Object sender, ExecutedRoutedEventArgs e)
   at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
   at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
   at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
   at System.Windows.Input.RoutedCommand.ExecuteImpl(Object parameter, IInputElement target, Boolean userInitiated)
   at Telerik.Windows.Controls.GridView.GridViewDataControl.ExecutePendingCommand()
   at Telerik.Windows.Controls.GridView.GridViewDataControl.PendAndExecuteCommands(KeyEventArgs e)
   at Telerik.Windows.Controls.GridView.GridViewDataControl.OnKeyDown(KeyEventArgs e)
   at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
   at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
   at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
   at System.Windows.UIElement.RaiseTrustedEvent(RoutedEventArgs args)
   at System.Windows.Input.InputManager.ProcessStagingArea()
   at System.Windows.Input.InputManager.ProcessInput(InputEventArgs input)
   at System.Windows.Interop.HwndKeyboardInputProvider.ReportInput(IntPtr hwnd, InputMode mode, Int32 timestamp, RawKeyboardActions actions, Int32 scanCode, Boolean isExtendedKey, Boolean isSystemKey, Int32 virtualKey)
   at System.Windows.Interop.HwndKeyboardInputProvider.ProcessKeyAction(MSG& msg, Boolean& handled)
   at System.Windows.Interop.HwndSource.CriticalTranslateAccelerator(MSG& msg, ModifierKeys modifiers)
   at System.Windows.Interop.HwndSource.OnPreprocessMessage(Object param)
   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
   at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)

6 Answers, 1 is accepted

Sort by
0
Sam
Top achievements
Rank 1
answered on 31 Oct 2011, 07:37 PM
Any one ? I tried 2011_2_0712 and was not able to reproduce till now..WPF 4 btw
0
Gautham
Top achievements
Rank 1
answered on 31 Oct 2011, 08:11 PM
i'am able to reproduce this in a sample app, following these steps.

Create a grid so that columns so that all columns are not visible.
Bind the a column to an int/decimal value (<telerik:GridViewDataColumn DataMemberBinding="{Binding Path=OrderUnits, Mode=TwoWay}" UniqueName="QuantityColumn" Header="Quantity" />)
enter edit mode in this column
scroll to the end of the grid view so that this column is out of view
scroll back to original location
tab out of edit.

Version - 2011.2.920.40
WPF4
0
test
Top achievements
Rank 1
answered on 06 Dec 2011, 02:01 PM
Hi,

I'm gettting the same error with WPF4, version 2011.3.1205.40:

Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.Reflection.TargetInvocationException
Stack:
   at Telerik.Windows.Controls.GridView.GridViewDataControl.RaiseDataErrorEvent(Telerik.Windows.Controls.GridView.DataErrorEventArgs)
   at Telerik.Windows.Controls.GridView.GridViewDataControl.CommitCurrentEdit(Telerik.Windows.Controls.GridView.GridViewRow)
   at Telerik.Windows.Controls.GridView.GridViewDataControl.PerformRowEditEnded(Telerik.Windows.Controls.GridView.GridViewCell)
   at Telerik.Windows.Controls.GridView.GridViewDataControl.CommitCellEdit(Telerik.Windows.Controls.GridView.GridViewCell, Boolean)
   at Telerik.Windows.Controls.GridView.GridViewDataControl.CommitEdit()
   at Telerik.Windows.Controls.GridView.GridViewCell.HandlePendingEdit()
   at Telerik.Windows.Controls.GridView.GridViewCell.HandlePendingEditOnLostFocus()
   at Telerik.Windows.Controls.GridView.GridViewCell.Editor_LostFocus(System.Object, System.Windows.RoutedEventArgs)
0
Robert
Top achievements
Rank 1
answered on 18 Apr 2017, 07:34 AM

One of our customers also get a NullReferenceException in GridViewDataControl.RaiseDataErrorEvent while working on a RadGridView with many columns.  This happens to the same user once or twice per week, some times a number of times the same day.  This is with 2017.1.222 and WPF.

The resemblance in stack trace is striking, though I've been unable to reproduce the error myself.  However, figuring out what can possibly give a NullReferenceException in RaiseDataErrorEvent is probably easier for the developers of that component than for me since I can't even reproduce this.

System.NullReferenceException: Object reference not set to an instance of an object.
   at Telerik.Windows.Controls.GridView.GridViewDataControl.RaiseDataErrorEvent(DataErrorEventArgs args)
   at Telerik.Windows.Controls.GridView.GridViewDataControl.CommitCurrentEdit(GridViewRow gridViewRow)
   at Telerik.Windows.Controls.GridView.GridViewDataControl.PerformRowEditEnded(GridViewCell currentCell)
   at Telerik.Windows.Controls.GridView.GridViewDataControl.CommitCellEdit(GridViewCell currentCell, Boolean isLeavingRow)
   at Telerik.Windows.Controls.GridView.GridViewDataControl.OnCurrentCellInfoChanging(GridViewCellInfo oldCell, GridViewCellInfo newCell)
   at Telerik.Windows.Controls.GridView.GridViewDataControl.set_CurrentCellInfo(GridViewCellInfo value)
   at Telerik.Windows.Controls.GridView.GridViewCell.OnGotFocus(RoutedEventArgs e)
   at System.Windows.UIElement.IsFocused_Changed(DependencyObject d, DependencyPropertyChangedEventArgs e)
   at System.Windows.DependencyObject.OnPropertyChanged(DependencyPropertyChangedEventArgs e)
   at System.Windows.FrameworkElement.OnPropertyChanged(DependencyPropertyChangedEventArgs e)
   at System.Windows.DependencyObject.NotifyPropertyChange(DependencyPropertyChangedEventArgs args)
   at System.Windows.DependencyObject.UpdateEffectiveValue(EntryIndex entryIndex, DependencyProperty dp, PropertyMetadata metadata, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType)
   at System.Windows.DependencyObject.SetValueCommon(DependencyProperty dp, Object value, PropertyMetadata metadata, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType, Boolean isInternal)
   at System.Windows.DependencyObject.SetValue(DependencyPropertyKey key, Object value)
   at System.Windows.Input.FocusManager.OnFocusedElementChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
   at System.Windows.DependencyObject.OnPropertyChanged(DependencyPropertyChangedEventArgs e)
   at System.Windows.FrameworkElement.OnPropertyChanged(DependencyPropertyChangedEventArgs e)
   at System.Windows.DependencyObject.NotifyPropertyChange(DependencyPropertyChangedEventArgs args)
   at System.Windows.DependencyObject.UpdateEffectiveValue(EntryIndex entryIndex, DependencyProperty dp, PropertyMetadata metadata, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType)
   at System.Windows.DependencyObject.SetValueCommon(DependencyProperty dp, Object value, PropertyMetadata metadata, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType, Boolean isInternal)
   at System.Windows.Input.FocusManager.SetFocusedElement(DependencyObject element, IInputElement value)
   at System.Windows.Input.KeyboardNavigation.UpdateFocusedElement(DependencyObject focusTarget)
   at System.Windows.FrameworkElement.OnGotKeyboardFocus(Object sender, KeyboardFocusChangedEventArgs e)
   at System.Windows.Input.KeyboardFocusChangedEventArgs.InvokeEventHandler(Delegate genericHandler, Object genericTarget)
   at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
   at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
   at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
   at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
   at System.Windows.UIElement.RaiseTrustedEvent(RoutedEventArgs args)
   at System.Windows.UIElement.RaiseEvent(RoutedEventArgs args, Boolean trusted)
   at System.Windows.Input.InputManager.ProcessStagingArea()
   at System.Windows.Input.InputManager.ProcessInput(InputEventArgs input)
   at System.Windows.Input.KeyboardDevice.ChangeFocus(DependencyObject focus, Int32 timestamp)
   at System.Windows.Input.KeyboardDevice.TryChangeFocus(DependencyObject newFocus, IKeyboardInputProvider keyboardInputProvider, Boolean askOld, Boolean askNew, Boolean forceToNullIfFailed)
   at System.Windows.Input.KeyboardDevice.Focus(DependencyObject focus, Boolean askOld, Boolean askNew, Boolean forceToNullIfFailed)
   at System.Windows.Input.KeyboardDevice.Focus(IInputElement element)
   at System.Windows.UIElement.Focus()
   at Telerik.Windows.Controls.GridView.GridViewCellBase.SetFocus()
   at Telerik.Windows.Controls.GridView.GridViewCell.OnMouseLeftButtonDown(MouseButtonEventArgs e)
   at System.Windows.UIElement.OnMouseLeftButtonDownThunk(Object sender, MouseButtonEventArgs e)
   at System.Windows.Input.MouseButtonEventArgs.InvokeEventHandler(Delegate genericHandler, Object genericTarget)
   at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
   at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
   at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
   at System.Windows.UIElement.ReRaiseEventAs(DependencyObject sender, RoutedEventArgs args, RoutedEvent newEvent)
   at System.Windows.UIElement.OnMouseDownThunk(Object sender, MouseButtonEventArgs e)
   at System.Windows.Input.MouseButtonEventArgs.InvokeEventHandler(Delegate genericHandler, Object genericTarget)
   at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
   at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
   at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
   at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
   at System.Windows.UIElement.RaiseTrustedEvent(RoutedEventArgs args)
   at System.Windows.UIElement.RaiseEvent(RoutedEventArgs args, Boolean trusted)
   at System.Windows.Input.InputManager.ProcessStagingArea()
   at System.Windows.Input.InputManager.ProcessInput(InputEventArgs input)
   at System.Windows.Input.InputProviderSite.ReportInput(InputReport inputReport)
   at System.Windows.Interop.HwndMouseInputProvider.ReportInput(IntPtr hwnd, InputMode mode, Int32 timestamp, RawMouseActions actions, Int32 x, Int32 y, Int32 wheel)
   at System.Windows.Interop.HwndMouseInputProvider.FilterMessage(IntPtr hwnd, WindowMessage msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   at System.Windows.Interop.HwndSource.InputFilterMessage(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
   at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)

0
Dilyan Traykov
Telerik team
answered on 18 Apr 2017, 04:56 PM
Hello Robert,

Without a sample project to debug at my end, I'm afraid I cannot give you a specific reason for this exception. Please note that the RaiseDataErrorEvent method simply checks if the exception has been handled in the DataError event and if not - throws the exception.

It does seem, however, that a data error is being thrown whilst modifying the bound data. With a bit more information regarding your exact setup - any validations you perform and the type of the bound data - as well as the action steps leading to the exception, I may be able to assist you further.

For the time being, I can suggest handling RadGridView's DataError event and setting the Handled property of the DataErrorEventArgs to True if you do not wish to throw a certain exception.

private void RadGridView_DataError(object sender, Telerik.Windows.Controls.GridView.DataErrorEventArgs e)
{
    var row = e.Row;
    var exception = e.Exception;
    e.KeepRowInEditMode = true;
    e.Handled = true;
}

As demonstrated in the example, you can also get ahold of the row and exception that triggered event.

I hope you find this information helpful.

Regards,
Dilyan Traykov
Telerik by Progress
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which you to write beautiful native mobile apps using a single shared C# codebase.
0
Robert
Top achievements
Rank 1
answered on 02 May 2017, 12:05 PM

For anyone who may stumble upon this thread in the future.  The problem is that RaiseDataErrorEvent will (for the time being) rethrow whatever exception it has detected, without properly wrapping it in a new exception.  This resets the stack trace, and for common exceptions makes it impossible to debug.

 

A feature request to fix it has been posted here: https://feedback.telerik.com/Project/143/Feedback/Details/215671-gridview-handle-exception-rethrow-inside-dataerror-event-so-that-stacktrace-and

 

Until then, a workaround is to wrap-up the exception yourself in the DataError event of RadGridView (just throw a new exception with the old one as InnerException.  The stacktrace of the outer-most exception will be reset, but the inner exception will survive.

Tags
GridView
Asked by
Gautham
Top achievements
Rank 1
Answers by
Sam
Top achievements
Rank 1
Gautham
Top achievements
Rank 1
test
Top achievements
Rank 1
Robert
Top achievements
Rank 1
Dilyan Traykov
Telerik team
Share this question
or