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

Failed to compare two elements in the array

1 Answer 242 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Ash
Top achievements
Rank 1
Ash asked on 23 Jul 2018, 02:49 PM

Hello, I am getting the below exception and I was wondering if there is any way to intercept the GridViewRowInfoComparer.CompareRows method to check for null values instead of throwing exception.

 

System.InvalidOperationException: Failed to compare two elements in the array. ---> System.NullReferenceException: Object reference not set to an instance of an object.
   at Telerik.WinControls.UI.GridViewRowInfoComparer.CompareRows(GridViewRowInfo x, GridViewRowInfo y, SortDescriptorCollection context)
   at Telerik.WinControls.UI.GridViewRowInfoComparer.Compare(GridViewRowInfo x, GridViewRowInfo y)
   at System.Collections.Generic.ArraySortHelper`1.InternalBinarySearch(T[] array, Int32 index, Int32 length, T value, IComparer`1 comparer)
   at System.Collections.Generic.ArraySortHelper`1.BinarySearch(T[] array, Int32 index, Int32 length, T value, IComparer`1 comparer)
   --- End of inner exception stack trace ---
   at System.Collections.Generic.ArraySortHelper`1.BinarySearch(T[] array, Int32 index, Int32 length, T value, IComparer`1 comparer)
   at System.Array.BinarySearch[T](T[] array, Int32 index, Int32 length, T value, IComparer`1 comparer)
   at System.Collections.Generic.List`1.BinarySearch(Int32 index, Int32 count, T item, IComparer`1 comparer)
   at System.Collections.Generic.List`1.BinarySearch(T item, IComparer`1 comparer)
   at Telerik.Collections.Generic.HybridIndex`1.PerformWithQuickSort()
   at Telerik.Collections.Generic.HybridIndex`1.Perform()
   at Telerik.Collections.Generic.HybridIndex`1.get_Items()
   at Telerik.WinControls.Data.RadDataView`1.get_Items()
   at Telerik.WinControls.Data.RadCollectionView`1.GetEnumerator()
   at Telerik.WinControls.UI.GridViewInfo.Refresh()
   at Telerik.WinControls.UI.GridViewInfo.get_ChildRows()
   at Telerik.WinControls.UI.GridViewTemplate.get_ChildRows()
   at Telerik.WinControls.UI.BaseGridNavigator.ProcessViewChangedEvent(GridViewEvent eventData)
   at Telerik.WinControls.UI.BaseGridNavigator.ProcessEventCore(GridViewEvent eventData)
   at Telerik.WinControls.UI.BaseGridNavigator.Telerik.WinControls.UI.IGridViewEventListener.ProcessEvent(GridViewEvent eventData)
   at Telerik.WinControls.UI.GridViewEventProcessEntity.ProcessCollection(GridViewEvent gridEvent, PriorityWeakReferenceList list, GridEventProcessMode processMode)
   at Telerik.WinControls.UI.GridViewEventProcessEntity.ProcessEvent(GridViewEvent gridEvent)
   at Telerik.WinControls.UI.GridViewSynchronizationService.NotifyListeners(GridViewEvent gridEvent)
   at Telerik.WinControls.UI.GridViewSynchronizationService.FlushEvents()
   at Telerik.WinControls.UI.GridViewSynchronizationService.DispatchEvent(GridViewEvent gridEvent)
   at Telerik.WinControls.UI.GridViewSynchronizationService.DispatchEvent(GridViewTemplate template, GridViewEvent eventData, Boolean postUI)
   at Telerik.WinControls.UI.GridViewTemplate.DispatchEvent(GridViewEvent gridEvent, Boolean postUI)
   at Telerik.WinControls.UI.GridViewTemplate.DispatchDataViewChangedEvent(Object sender, DataViewChangedEventArgs args)
   at Telerik.WinControls.UI.GridViewTemplate.OnViewChanged(Object sender, DataViewChangedEventArgs e)
   at Telerik.WinControls.UI.MasterGridViewTemplate.OnViewChanged(Object sender, DataViewChangedEventArgs e)
   at Telerik.WinControls.UI.GridViewTemplate.CollectionView_CollectionChanged(Object sender, NotifyCollectionChangedEventArgs e)
   at Telerik.WinControls.Data.RadCollectionView`1.OnCollectionChanged(NotifyCollectionChangedEventArgs args)
   at Telerik.WinControls.Data.RadDataView`1.RebuildData(Boolean notify)
   at Telerik.WinControls.Data.RadDataView`1.RefreshOverride()
   at Telerik.WinControls.Data.RadDataView`1.OnNotifyPropertyChanged(PropertyChangedEventArgs e)
   at Telerik.WinControls.Data.RadCollectionView`1.OnNotifyPropertyChanged(String propertyName)
   at Telerik.WinControls.Data.RadCollectionView`1.set_FilterExpression(String value)
   at Telerik.WinControls.UI.GridViewFilterDescriptorCollection.ApplyFilter()
   at Telerik.WinControls.UI.GridViewFilterDescriptorCollection.OnCollectionChanged(NotifyCollectionChangedEventArgs args)
   at Telerik.Collections.Generic.NotifyCollection`1.ClearItems()
   at Telerik.WinControls.UI.GridViewFilterDescriptorCollection.ClearItems()
   at System.Collections.ObjectModel.Collection`1.Clear()
   at Telerik.WinControls.UI.GridViewTemplate.RefreshFilterDescriptors(GridViewTemplate template)
   at Telerik.WinControls.UI.GridViewTemplate.RefreshHierarchyProvider(GridViewTemplate template)
   at Telerik.WinControls.UI.GridViewTemplate.set_DataSource(Object value)
   at Telerik.WinControls.UI.RadGridView.set_DataSource(Object value)

Many thanks.

 

1 Answer, 1 is accepted

Sort by
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 24 Jul 2018, 07:44 AM
Hello, Ash,    

The provided stack trace is greatly appreciated. However, it is difficult to determine what is the exact problem and what causes the error on your end. Would it be possible to provide a code snippet resulting in the illustrated error? Thus, we would be able to make an adequate analysis of the precise case and assist you further. Thank you in advance for the cooperation.

I am looking forward to your reply.

Regards,
Dess
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
GridView
Asked by
Ash
Top achievements
Rank 1
Answers by
Dess | Tech Support Engineer, Principal
Telerik team
Share this question
or