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

NullReferenceException in Grid when Items are empty

1 Answer 38 Views
GridView
This is a migrated thread and some comments may be shown as answers.
rthorat
Top achievements
Rank 1
rthorat asked on 07 Jan 2010, 07:47 PM
We are using version 2009.1.526.35 of the GridView control. In some situations, we are encountering NullReferenceExceptions when the GridView attempts to layout with no items in it. We have found this problem happening under at least 2 scenarios:

1) Calling ApplyTemplate() on the GridView and all of its template children recursively.

2) Clearing/Removing all items from the GridView (in this case it seems to happen randomly - definitely not always).

In both cases, the problem is in the Measure pass and appears to be a problem with the GridView's panel. Looks like it is trying to access an item or the first item in the Grid when it is empty.

1) Is this a known issue?
2) Is it fixed in a newer version of the control?

Stack Trace:

   at System.ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgumentargument, ExceptionResource resource)

   at System.ThrowHelper.ThrowArgumentOutOfRangeException()

   at System.Collections.Generic.List`1.get_Item(Int32 index)

   atTelerik.Windows.Controls.GridView.GridViewVirtualizingPanel.GetChildIndexByPhysicalOffset(Doubleoffset)

   atTelerik.Windows.Controls.GridView.GridViewVirtualizingPanel.UpdateFirstVisibleChildIndex(Doubleoffset)

   atTelerik.Windows.Controls.GridView.GridViewVirtualizingPanel.SetVerticalOffset(Doubleoffset)

   atTelerik.Windows.Controls.GridView.GridViewVirtualizingPanel.ResetVerticalOffset()

   atTelerik.Windows.Controls.GridView.BaseVirtualizingPanel.MeasureOverride(SizeavailableSize)

   at System.Windows.FrameworkElement.MeasureCore(Size availableSize)

   at System.Windows.UIElement.Measure(Size availableSize)

   at System.Windows.ContextLayoutManager.UpdateLayout()

   at System.Windows.ContextLayoutManager.UpdateLayoutCallback(Objectarg)

   at System.Windows.Media.MediaContext.InvokeOnRenderCallback.DoWork()

   at System.Windows.Media.MediaContext.FireInvokeOnRenderCallbacks()

   at System.Windows.Media.MediaContext.RenderMessageHandlerCore(ObjectresizedCompositionTarget)

   at System.Windows.Media.MediaContext.RenderMessageHandler(ObjectresizedCompositionTarget)

   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegatecallback, Object args, Boolean isSingleParameter)

   at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source,Delegate callback, Object args, Boolean isSingleParameter, DelegatecatchHandler)

1 Answer, 1 is accepted

Sort by
0
Vlad
Telerik team
answered on 08 Jan 2010, 07:31 AM
Hello rthorat,

Indeed these problems were fixed and I suggest you to try our latest release Q3 2009 SP1.

Regards,
Vlad
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
GridView
Asked by
rthorat
Top achievements
Rank 1
Answers by
Vlad
Telerik team
Share this question
or