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

Filter on null Float values throwing exception

4 Answers 50 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Bob
Top achievements
Rank 1
Veteran
Bob asked on 01 Mar 2012, 05:17 PM

I have a data bound column on a float field.  Some of the float values are null in the database.  When I filter on the column when all values are not null, the filter works fine.  When I filter on the column with null values included, I get an exception in Telerik code, "Nullable object must have a value."  Here is the call stack when the exception is thrown:
:

  Telerik.Windows.Data.dll!Telerik.Windows.Data.QueryableExtensions.Count(System.Linq.IQueryable source) Line 399 + 0x18b bytes C#
  Telerik.Windows.Data.dll!Telerik.Windows.Data.QueryableCollectionView.GetPagingDeterminativeItemCount() Line 413 + 0x86 bytes C#
  Telerik.Windows.Data.dll!Telerik.Windows.Data.QueryableCollectionView.PagingDeterminativeItemCount.get() Line 405 + 0x14 bytes C#
  Telerik.Windows.Data.dll!Telerik.Windows.Data.QueryableCollectionView.GetEffectiveItemCount() Line 388 + 0xa bytes C#
  Telerik.Windows.Data.dll!Telerik.Windows.Data.QueryableCollectionView.UpdateItemCount() Line 381 + 0x1e bytes C#
  Telerik.Windows.Data.dll!Telerik.Windows.Data.QueryableCollectionView.OnInternalListCreated() Line 783 C#
  Telerik.Windows.Data.dll!Telerik.Windows.Data.QueryableCollectionView.EnsureInternalList() Line 643 C#
  Telerik.Windows.Data.dll!Telerik.Windows.Data.QueryableCollectionView.InternalList.get() Line 632 C#
  Telerik.Windows.Data.dll!Telerik.Windows.Data.QueryableCollectionView.InternalCount.get() Line 319 + 0x17 bytes C#
  Telerik.Windows.Data.dll!Telerik.Windows.Data.QueryableCollectionView.IsEmpty.get() Line 277 + 0x14 bytes C#
  Telerik.Windows.Data.dll!Telerik.Windows.Data.DataItemCollection.IsEmpty.get() Line 355 + 0x21 bytes C#
  Telerik.Windows.Controls.GridView.dll!Telerik.Windows.Controls.GridView.BaseItemsControl.OnItemCollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e) Line 690 + 0x66 bytes C#
  Telerik.Windows.Data.dll!Telerik.Windows.Data.DataItemCollection.OnCollectionChanged(System.Collections.Specialized.NotifyCollectionChangedEventArgs e) Line 636 C#
  Telerik.Windows.Data.dll!Telerik.Windows.Data.DataItemCollection.OnCollectionViewCollectionChanged(System.Collections.Specialized.NotifyCollectionChangedEventArgs e) Line 615 C#
  Telerik.Windows.Data.dll!Telerik.Windows.Data.DataItemCollection.Telerik.Windows.Data.IWeakEventListener<System.Collections.Specialized.NotifyCollectionChangedEventArgs>.ReceiveWeakEvent(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e) Line 1050 C#
  Telerik.Windows.Data.dll!Telerik.Windows.Data.WeakEvent.WeakListener<System.Collections.Specialized.NotifyCollectionChangedEventArgs>.Handler(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs args) Line 33 + 0x69 bytes C#
  Telerik.Windows.Data.dll!Telerik.Windows.Data.QueryableCollectionView.OnCollectionChanged(System.Collections.Specialized.NotifyCollectionChangedEventArgs args) Line 875 C#
  Telerik.Windows.Data.dll!Telerik.Windows.Data.QueryableCollectionView.RefreshOverride() Line 1022 C#
  Telerik.Windows.Data.dll!Telerik.Windows.Data.QueryableCollectionView.RefreshInternal() Line 970 C#
  Telerik.Windows.Data.dll!Telerik.Windows.Data.QueryableCollectionView.RefreshOrDefer() Line 965 C#
  Telerik.Windows.Data.dll!Telerik.Windows.Data.QueryableCollectionView.InvalidatePagingAndRefresh() Line 438 C#
  Telerik.Windows.Data.dll!Telerik.Windows.Data.QueryableCollectionView.OnFilterDescriptorsCollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e) Line 473 C#
  [External Code]
  Telerik.Windows.Data.dll!Telerik.Windows.Data.RadObservableCollection<Telerik.Windows.Data.IFilterDescriptor>.OnCollectionChanged(System.Collections.Specialized.NotifyCollectionChangedEventArgs e) Line 149 + 0xf bytes C#
  Telerik.Windows.Data.dll!Telerik.Windows.Data.ObservableItemCollection<Telerik.Windows.Data.IFilterDescriptor>.OnCollectionChanged(System.Collections.Specialized.NotifyCollectionChangedEventArgs e) Line 93 C#
  Telerik.Windows.Data.dll!Telerik.Windows.Data.RadObservableCollection<Telerik.Windows.Data.IFilterDescriptor>.InsertItem(int index, Telerik.Windows.Data.IFilterDescriptor item) Line 196 C#
  [External Code]
  Telerik.Windows.Data.dll!Telerik.Windows.Data.CollectionHelper.Insert(System.Collections.IList target, System.Collections.IEnumerable newItems, int startingIndex, System.Collections.IEqualityComparer itemComparer) Line 334 + 0x44 bytes C#
  Telerik.Windows.Data.dll!Telerik.Windows.Data.ObservableCollectionManager.HandleCollectionChanged(System.Collections.IList sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs args) Line 106 C#
  Telerik.Windows.Data.dll!Telerik.Windows.Data.ObservableCollectionManager.Telerik.Windows.Data.IWeakEventListener<System.Collections.Specialized.NotifyCollectionChangedEventArgs>.ReceiveWeakEvent(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs args) Line 87 C#
  Telerik.Windows.Data.dll!Telerik.Windows.Data.WeakEvent.WeakListener<System.Collections.Specialized.NotifyCollectionChangedEventArgs>.Handler(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs args) Line 33 + 0x69 bytes C#
  [External Code]
  Telerik.Windows.Data.dll!Telerik.Windows.Data.RadObservableCollection<Telerik.Windows.Data.IFilterDescriptor>.OnCollectionChanged(System.Collections.Specialized.NotifyCollectionChangedEventArgs e) Line 149 + 0xf bytes C#
  Telerik.Windows.Data.dll!Telerik.Windows.Data.ObservableItemCollection<Telerik.Windows.Data.IFilterDescriptor>.OnCollectionChanged(System.Collections.Specialized.NotifyCollectionChangedEventArgs e) Line 93 C#
  Telerik.Windows.Data.dll!Telerik.Windows.Data.RadObservableCollection<Telerik.Windows.Data.IFilterDescriptor>.InsertItem(int index, Telerik.Windows.Data.IFilterDescriptor item) Line 196 C#
  Telerik.Windows.Controls.GridView.dll!Telerik.Windows.Controls.GridView.FilteringViewModel.OnPropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) Line 551 + 0x3b bytes C#
  Telerik.Windows.Controls.dll!Telerik.Windows.Controls.ViewModelBase.OnPropertyChanged(string propertyName) Line 58 C#
  Telerik.Windows.Controls.GridView.dll!Telerik.Windows.Controls.GridView.FilteringViewModel.ApplyFilters() Line 459 C#
  Telerik.Windows.Controls.GridView.dll!Telerik.Windows.Controls.GridView.FilteringViewModel.OnFieldFilterPropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) Line 386 C#
  Telerik.Windows.Controls.dll!Telerik.Windows.Controls.ViewModelBase.OnPropertyChanged(string propertyName) Line 58 C#
  Telerik.Windows.Controls.GridView.dll!Telerik.Windows.Controls.GridView.FilterDescriptorViewModel.Value.set(object value) Line 103 C#
  [External Code]
  Telerik.Windows.Controls.Input.dll!Telerik.Windows.Controls.RadMaskedTextBox.Value.set(object value) Line 376 C#
  Telerik.Windows.Controls.Input.dll!Telerik.Windows.Controls.RadMaskedTextBox.UpdateValueFromHandler() Line 1444 C#
  Telerik.Windows.Controls.Input.dll!Telerik.Windows.Controls.RadMaskedTextBox.TextBox_LostFocus() Line 877 + 0xd bytes C#
  Telerik.Windows.Controls.Input.dll!Telerik.Windows.Controls.MaskedTextBox.ExtendedTextBox.OnLostFocus(System.Windows.RoutedEventArgs e) Line 53 C#
  [External Code]






4 Answers, 1 is accepted

Sort by
0
Rossen Hristov
Telerik team
answered on 02 Mar 2012, 09:12 AM
Hi,

Is your business object property defined as Nullable<float> or as a simple float? Because a plain old float cannot be null since it is a value type.

Can you please send us some kind of dummy sample project that we can run and debug to see what is going on.

Thanks in advance.

Kind regards,
Ross
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
0
Bob
Top achievements
Rank 1
Veteran
answered on 02 Mar 2012, 06:10 PM
Hi Ross,

The entity object had this field defined as double?.  I tried changing to Nullable<double>, but I still get the same exception.  I then changed to Nullable<float> and cast to that, and it seems to work.

So the problem is double.  Is that a known issue?
0
Rossen Hristov
Telerik team
answered on 05 Mar 2012, 09:12 AM
Hi,

That is not a known issue and unfortunately we were not able to reproduce it.

You would help is greatly if you send us some kind of dummy sample project that we can run and debug to see what is going on. 

Kind regards,
Ross
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
0
Bob
Top achievements
Rank 1
Veteran
answered on 05 Mar 2012, 07:08 PM
Hi Ross,

I got a couple people to look into this, and it appears to be an issue with our data.  We create dynamic classes and properties on our data, and use custom predicate and LINQ to resolve filter expressions.  During the construction of the custom filter predicates, the double type did not appear to be handled correctly, and for whatever reason was causing the exception in the Telerik code when filtering was executed.  Once we corrected the faulty dynamic construction of the double field and filter, the exception was gone.  The exception was thrown on a separate thread in Telerik code, so it was very difficult to determine why the double field was the problem.

Thanks for your help,
Bob
Tags
GridView
Asked by
Bob
Top achievements
Rank 1
Veteran
Answers by
Rossen Hristov
Telerik team
Bob
Top achievements
Rank 1
Veteran
Share this question
or