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

Object reference not set to an instance of an object. at Telerik.WinControls.UI.GridViewEditManager.OnPositionChanging

3 Answers 529 Views
GridView
This is a migrated thread and some comments may be shown as answers.
CHRIS
Top achievements
Rank 1
CHRIS asked on 09 Sep 2013, 06:26 PM
Telerik.WinControls.GridView version 2012.3.1211.20

Hi Everyone,

I am using GridView's RowSourceNeeded to populate child table when [+] is clicked... it works fine when initial load, however when master table gets refreshed by assigning the DataSource to different collection, it throws following error when [+] is clicked to populate child table.
It seems the child table was populated OK, but it still throws the exception anyway.

Any help/suggestions/ideas are appreciated greatly.  Thank you.

System.NullReferenceException: Object reference not set to an instance of an object.
   at Telerik.WinControls.UI.GridViewEditManager.OnPositionChanging(PositionChangingEventArgs args)
   at Telerik.WinControls.UI.GridViewEditManager.Telerik.WinControls.UI.IGridViewEventListener.PreProcessEvent(GridViewEvent eventData)
   at Telerik.WinControls.UI.GridViewEventProcessEntity.ProcessCollection(GridViewEvent gridEvent, PriorityWeakReferenceList list, GridEventProcessMode processMode)
   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.RaiseCurrentChanged(GridViewTemplate template, GridViewRowInfo row, GridViewColumn column, Boolean user)
   at Telerik.WinControls.UI.GridViewRowInfo.OnIsCurrentPropertyChanging(PropertyChangingEventArgsEx args)
   at Telerik.WinControls.UI.GridViewRowInfo.OnPropertyChanging(PropertyChangingEventArgsEx args)
   at Telerik.WinControls.UI.GridViewHierarchyRowInfo.OnPropertyChanging(PropertyChangingEventArgsEx args)
   at Telerik.WinControls.UI.GridViewRowInfo.SetBooleanProperty(String propertyName, Int32 propertyKey, Boolean value)
   at Telerik.WinControls.UI.MasterGridViewTemplate.ChangeCurrentRow(GridViewRowInfo oldRow, GridViewRowInfo row, GridViewTemplate viewTemplate)
   at Telerik.WinControls.UI.MasterGridViewTemplate.SetPositionCore(GridViewRowInfo newRow, GridViewColumn newColumn, GridViewRowInfo oldRow, GridViewColumn oldColumn, Boolean validateRowChange)
   at Telerik.WinControls.UI.MasterGridViewTemplate.SetPosition(GridViewRowInfo row, GridViewColumn column, Boolean validateRowChange)
   at Telerik.WinControls.UI.MasterGridViewTemplate.ProcessCurrentChanged(GridViewEvent eventData)
   at Telerik.WinControls.UI.MasterGridViewTemplate.ProcessEventCore(GridViewEvent eventData)
   at Telerik.WinControls.UI.GridViewEventProcessEntity.ProcessCollection(GridViewEvent gridEvent, PriorityWeakReferenceList list, GridEventProcessMode processMode)
   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.RaiseCurrentChanged(GridViewTemplate template, GridViewRowInfo row, GridViewColumn column, Boolean user)
   at Telerik.WinControls.UI.BaseGridNavigator.SelectCore(GridViewRowInfo row, GridViewColumn column)
   at Telerik.WinControls.UI.GridRowBehavior.SelectPositionOnMouseDownLeft(MouseEventArgs e, GridRowElement rowElement, GridCellElement cellElement)
   at Telerik.WinControls.UI.GridRowBehavior.OnMouseDownLeft(MouseEventArgs e)
   at Telerik.WinControls.UI.GridRowBehavior.OnMouseDown(MouseEventArgs e)
   at Telerik.WinControls.UI.BaseGridBehavior.OnMouseDown(MouseEventArgs e)
   at Telerik.WinControls.UI.RadGridView.OnMouseDown(MouseEventArgs e)
   at System.Windows.Forms.Control.WmMouseDown(Message& m, MouseButtons button, Int32 clicks)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at Telerik.WinControls.RadControl.WndProc(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

3 Answers, 1 is accepted

Sort by
0
George
Telerik team
answered on 12 Sep 2013, 11:31 AM
Hello Chris,

Thank you for contacting Telerik Support.

You should not change the DataSource in the RowSourceNeeded event. You can either only add/remove rows or try to replace the collection on the ChildViewExpanded event. Additionally you can read more about Load-On-Demand in this help article - http://www.telerik.com/help/winforms/gridview-hierarchical-grid-load-on-demand-hierarchy.html.

If you still experience issues, feel free to contact me back with a sample project which can help me get your idea and properly investigate your case.

I hope this helps.

Regards,
George
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WINFORMS.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
0
CHRIS
Top achievements
Rank 1
answered on 12 Sep 2013, 04:59 PM
Hi George,

Thanks for the reply.

The problem was not really caused by RowSourceNeeded event.

I have two gridviews and they shared same Child templates and HierachyDataProvider...

I created dedicated Child templates and HierachyDataProvider for each GridView and the exception seems gone.

Regards,


Chris
0
George
Telerik team
answered on 17 Sep 2013, 03:50 PM
Hi Chris,

I am glad that you resolved your issue.

Should you have any other questions, do not hesitate to ask.
 
Regards,
George
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WINFORMS.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
Tags
GridView
Asked by
CHRIS
Top achievements
Rank 1
Answers by
George
Telerik team
CHRIS
Top achievements
Rank 1
Share this question
or