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

Grouping on Nullable Column

3 Answers 39 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Scott Rakestraw
Top achievements
Rank 1
Scott Rakestraw asked on 12 Mar 2010, 03:04 PM
I am using the Q1 2010 release and any columns that I have that contain nullable data throw an error when I group by them.

System.InvalidOperationException: Nullable object must have a value. 
   at System.ThrowHelper.ThrowInvalidOperationException(ExceptionResource resource) 
   at System.Nullable`1.get_Value() 
   at lambda_method(ExecutionScope , Table ) 
   at System.Linq.Lookup`2.Create[TSource](IEnumerable`1 source, Func`2 keySelector, Func`2 elementSelector, IEqualityComparer`1 comparer) 
   at System.Linq.GroupedEnumerable`3.GetEnumerator() 
   at System.Linq.Buffer`1..ctor(IEnumerable`1 source) 
   at System.Linq.OrderedEnumerable`1.<GetEnumerator>d__0.MoveNext() 
   at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext() 
   at Telerik.Windows.Data.QueryableCollectionView.PopulateInternalList(IQueryable view) 
   at Telerik.Windows.Data.QueryableCollectionView.CreateInternalList() 
   at Telerik.Windows.Data.QueryableCollectionView.EnsureInternalList() 
   at Telerik.Windows.Data.QueryableCollectionView.get_Groups() 
   at Telerik.Windows.Controls.GridView.GridViewItemContainerGenerator.PrepareGrouping() 
   at Telerik.Windows.Controls.GridView.GridViewItemContainerGenerator.System.Windows.Controls.Primitives.IItemContainerGenerator.RemoveAll() 
   at Telerik.Windows.Controls.GridView.GridViewItemContainerGenerator.OnRefresh() 
   at Telerik.Windows.Controls.GridView.GridViewItemContainerGenerator.Refresh() 
   at Telerik.Windows.Controls.GridView.GridViewDataControl.ItemsSourceChanged(Boolean sourceChanged) 
   at Telerik.Windows.Controls.GridView.GridViewDataControl.OnItemsChanged(NotifyCollectionChangedEventArgs e) 
   at Telerik.Windows.Controls.GridView.BaseItemsControl.OnItemCollectionChanged(Object sender, NotifyCollectionChangedEventArgs e) 
   at System.Collections.Specialized.NotifyCollectionChangedEventHandler.Invoke(Object sender, NotifyCollectionChangedEventArgs e) 
   at Telerik.Windows.Data.DataItemCollection.OnCollectionChanged(NotifyCollectionChangedEventArgs e) 
   at Telerik.Windows.Data.DataItemCollection.Telerik.Windows.Data.IWeakEventListener<System.Collections.Specialized.NotifyCollectionChangedEventArgs>.ReceiveWeakEvent(Object sender, NotifyCollectionChangedEventArgs e) 
   at Telerik.Windows.Data.WeakEvent.WeakListener`1.Handler(Object sender, TArgs args) 
   at System.Collections.Specialized.NotifyCollectionChangedEventHandler.Invoke(Object sender, NotifyCollectionChangedEventArgs e) 
   at Telerik.Windows.Data.QueryableCollectionView.OnCollectionChanged(NotifyCollectionChangedEventArgs args) 
   at Telerik.Windows.Data.QueryableCollectionView.RefreshAndRaiseCollectionChanged(NotifyCollectionChangedEventArgs args) 
   at Telerik.Windows.Data.QueryableCollectionView.Refresh() 
   at Telerik.Windows.Data.QueryableCollectionView.EndDefer() 
   at Telerik.Windows.Data.QueryableCollectionView.DeferHelper.Dispose() 
   at Telerik.Windows.Controls.GridView.GridViewDataControl.PerformGrouping(GroupingRequestedEventArgs args) 
   at Telerik.Windows.Controls.GridView.GridViewDataControl.<>c__DisplayClass2b.<GroupingRequested>b__2a() 
   at Telerik.Windows.Controls.CursorManager.PerformTimeConsumingOperation(FrameworkElement frameworkElement, Action action) 
   at Telerik.Windows.Controls.GridView.GridViewDataControl.GroupingRequested(Object origin, GroupingRequestedEventArgs e) 

3 Answers, 1 is accepted

Sort by
0
Stefan Dobrev
Telerik team
answered on 12 Mar 2010, 05:07 PM
Hello Scott,

I have tried to replicate your issue on my side, but everything works as expected. Maybe I'm missing something from your scenario. I'm sending you my sample project. You can group by the "Number" column, which is nullable int and see that it is working fine.

Kind regards,
Stefan Dobrev
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Scott Rakestraw
Top achievements
Rank 1
answered on 12 Mar 2010, 06:00 PM
I found out that my problem was that I was using metadata to build the columns and was setting all date columns to have datatype of date when some of them are nullable.  Is there any reason to explicitly set the datatype for a column?  I have removed that and it all appears to be working fine now.
0
Stefan Dobrev
Telerik team
answered on 12 Mar 2010, 06:29 PM
Hello Scott,

You should set DataType on columns when the column's data type cannot be resoled by RadGridView or the property type of your object is of type let say object, but the actual stored values are string for example. So setting data type in your case is not necessary.

Greetings,
Stefan Dobrev
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Tags
GridView
Asked by
Scott Rakestraw
Top achievements
Rank 1
Answers by
Stefan Dobrev
Telerik team
Scott Rakestraw
Top achievements
Rank 1
Share this question
or