Cannot set DataSource second time

7 posts, 0 answers
  1. MaxeL
    MaxeL avatar
    5 posts
    Member since:
    Aug 2012

    Posted 22 Dec 2012 Link to this post

    hi, i am trying q3 sp1.

    i have function:

    public void UpdateData()
    {

    this.CategoryView.AllowAddNewRow = false;
    this.CategoryView.TableElement.RowHeight = 40;
    this.CategoryView.ReadOnly = true;
    this.CategoryView.TableElement.RowSpacing = 2;
    this.CategoryView.TableElement.ShowSelfReferenceLines = true;
    this.CategoryView.SelectionMode = Telerik.WinControls.UI.GridViewSelectionMode.FullRowSelect;

    this.CategoryView.MasterTemplate.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill;
        DataTable source = CreateDataSource();    // this function work correct
    if (this.CategoryView.DataSource != null)
    {
    string s = this.CategoryView.DataSource.ToString();           // s has a value
    }
    this.CategoryView.DataSource = source;  ///!!!!!!!!!!!!!!!!!!!!here i have problem  "Object reference not set to an instance of an object."

    this.CategoryView.MasterTemplate.SortDescriptors.Add("lastupdate", ListSortDirection.Descending);
    this.CategoryView.Relations.AddSelfReference(this.CategoryView.MasterTemplate, "id", "parent_id");
    this.CategoryView.Columns["id"].IsVisible = false;
    this.CategoryView.Columns["sn"].IsVisible = false;
    this.CategoryView.Columns["parent_id"].IsVisible = false;
    this.CategoryView.Columns["is_comment"].IsVisible = false;
    this.CategoryView.Columns["fulltext"].IsVisible = false;
    this.CategoryView.Columns["pubdate"].IsVisible = false;
    this.CategoryView.Columns["source"].IsVisible = false;
    this.CategoryView.Columns["category"].IsVisible = false;
    this.CategoryView.Columns["lastupdate"].IsVisible = false;
    this.CategoryView.Columns["title"].WrapText = true;
        }

    the problem start from the second call of function, first call work fine:

    System.NullReferenceException не обработано пользовательским кодом
    Message="Object reference not set to an instance of an object."
    Source="Telerik.WinControls.GridView"
    StackTrace:
    at Telerik.WinControls.UI.GridViewCellInfoCollection.get_Item(String name)
    at Telerik.WinControls.UI.GridDataCellElement.UpdateInfoCore()
    at Telerik.WinControls.UI.GridCellElement.UpdateInfo()
    at Telerik.WinControls.UI.GridTableElement.UpdateCellContentByColumn(GridViewColumn column)
    at Telerik.WinControls.UI.GridTableElement.UpdateViewCore(Object sender, DataViewChangedEventArgs args)
    at Telerik.WinControls.UI.GridTableElement.UpdateView(Object sender, DataViewChangedEventArgs args)
    at Telerik.WinControls.UI.GridTableElement.ProcessTemplateEvent(GridViewEvent eventData)
    at Telerik.WinControls.UI.GridTableElement.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.GridViewSelfReferenceDataProvider.DispatchDataViewChangedEvent(DataViewChangedEventArgs args)
    at Telerik.WinControls.UI.GridViewSelfReferenceDataProvider.Refresh()
    at Telerik.WinControls.UI.GridViewTemplate.Telerik.WinControls.Data.IDataItemSource.Initialize()
    at Telerik.WinControls.Data.RadListSource`1.Initialize()
    at Telerik.WinControls.Data.RadListSource`1.Bind(Object dataSource, String dataMember)
    at Telerik.WinControls.Data.RadListSource`1.set_DataSource(Object value)
    at Telerik.WinControls.UI.GridViewTemplate.set_DataSource(Object value)
    at Telerik.WinControls.UI.RadGridView.set_DataSource(Object value)
    at AgroCenterCommunity.LawsForm.UpdateData() in C:\Documents and Settings\mxL\My Documents\Visual Studio 2008\Projects\ACK_01\ACK_01\LawsForm.cs:line 246
    at AgroCenterCommunity.LawsForm.LawsForm_Load(Object sender, EventArgs e) in C:\Documents and Settings\mxL\My Documents\Visual Studio 2008\Projects\ACK_01\ACK_01\LawsForm.cs:line 221
    at System.Windows.Forms.Form.OnLoad(EventArgs e)
    at System.Windows.Forms.Form.OnCreateControl()
    at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
    at System.Windows.Forms.Control.CreateControl()
    at System.Windows.Forms.Control.WmShowWindow(Message& m)
    at System.Windows.Forms.Control.WndProc(Message& m)
    at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
    at System.Windows.Forms.ContainerControl.WndProc(Message& m)
    at System.Windows.Forms.Form.WmShowWindow(Message& m)
    at System.Windows.Forms.Form.WndProc(Message& m)
    at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
    at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
    at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
    at System.Windows.Forms.UnsafeNativeMethods.IntCreateWindowEx(Int32 dwExStyle, String lpszClassName, String lpszWindowName, Int32 style, Int32 x, Int32 y, Int32 width, Int32 height, HandleRef hWndParent, HandleRef hMenu, HandleRef hInst, Object pvParam)
    at System.Windows.Forms.UnsafeNativeMethods.CreateWindowEx(Int32 dwExStyle, String lpszClassName, String lpszWindowName, Int32 style, Int32 x, Int32 y, Int32 width, Int32 height, HandleRef hWndParent, HandleRef hMenu, HandleRef hInst, Object pvParam)
    at System.Windows.Forms.NativeWindow.CreateHandle(CreateParams cp)
    InnerException:

    "string s" return a value, but then on next line VS2008 tell, that "Object reference not set to an instance of an object."

    Need help.

    insert
    CategoryView.MasterTemplate.Reset();  before  DataTable source = CreateDataSource();
    and have this:

    System.Reflection.TargetInvocationException не обработано
    Message="Exception has been thrown by the target of an invocation."
    Source="mscorlib"
    StackTrace:
    at System.RuntimeMethodHandle._InvokeConstructor(Object[] args, SignatureStruct& signature, IntPtr declaringType)
    at System.RuntimeMethodHandle.InvokeConstructor(Object[] args, SignatureStruct signature, RuntimeTypeHandle declaringType)
    at System.Reflection.RuntimeConstructorInfo.Invoke(BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
    at System.RuntimeType.CreateInstanceImpl(BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes)
    at System.Activator.CreateInstance(Type type, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes)
    at Telerik.WinControls.UI.GridRowElement.CreateCell(GridViewColumn column)
    at Telerik.WinControls.UI.GridDataRowElement.CreateCell(GridViewColumn column)
    at Telerik.WinControls.UI.CellElementProvider.CreateElement(GridViewColumn data, Object context)
    at Telerik.WinControls.UI.CellElementProvider.GetElement(GridViewColumn data, Object context)
    at Telerik.WinControls.UI.BaseVirtualizedContainer`1.UpdateElement(Int32 position, T data)
    at Telerik.WinControls.UI.BaseVirtualizedContainer`1.MeasureElements()
    at Telerik.WinControls.UI.BaseVirtualizedContainer`1.MeasureOverride(SizeF availableSize)
    at Telerik.WinControls.RadElement.MeasureCore(SizeF availableSize)
    at Telerik.WinControls.RadElement.Measure(SizeF availableSize)
    at Telerik.WinControls.UI.GridVirtualizedRowElement.MeasureElements(SizeF availableSize, SizeF clientSize, Padding borderThickness)
    at Telerik.WinControls.UI.LightVisualElement.MeasureOverride(SizeF availableSize)
    at Telerik.WinControls.UI.GridRowElement.MeasureOverride(SizeF availableSize)
    at Telerik.WinControls.RadElement.MeasureCore(SizeF availableSize)
    at Telerik.WinControls.RadElement.Measure(SizeF availableSize)
    at Telerik.WinControls.UI.VirtualizedStackContainer`1.MeasureElementCore(RadElement element, SizeF availableSize)
    at Telerik.WinControls.UI.ScrollableRowsContainerElement.MeasureElementCore(RadElement element, SizeF availableSize)
    at Telerik.WinControls.UI.VirtualizedStackContainer`1.MeasureElement(IVirtualizedElement`1 element)
    at Telerik.WinControls.UI.BaseVirtualizedContainer`1.MeasureElements()
    at Telerik.WinControls.UI.BaseVirtualizedContainer`1.MeasureOverride(SizeF availableSize)
    at Telerik.WinControls.UI.ScrollableRowsContainerElement.MeasureOverride(SizeF availableSize)
    at Telerik.WinControls.RadElement.MeasureCore(SizeF availableSize)
    at Telerik.WinControls.RadElement.Measure(SizeF availableSize)
    at Telerik.WinControls.UI.RowsContainerElement.MeasureOverride(SizeF availableSize)
    at Telerik.WinControls.RadElement.MeasureCore(SizeF availableSize)
    at Telerik.WinControls.RadElement.Measure(SizeF availableSize)
    at Telerik.WinControls.UI.ScrollViewElement`1.MeasureViewElement(SizeF availableSize)
    at Telerik.WinControls.UI.ScrollViewElement`1.MeasureView(SizeF availableSize)
    at Telerik.WinControls.UI.ScrollViewElement`1.MeasureOverride(SizeF availableSize)
    at Telerik.WinControls.UI.GridTableElement.MeasureOverride(SizeF availableSize)
    at Telerik.WinControls.RadElement.MeasureCore(SizeF availableSize)
    at Telerik.WinControls.RadElement.Measure(SizeF availableSize)
    at Telerik.WinControls.Layouts.DockLayoutPanel.MeasureOverride(SizeF constraint)
    at Telerik.WinControls.RadElement.MeasureCore(SizeF availableSize)
    at Telerik.WinControls.RadElement.Measure(SizeF availableSize)
    at Telerik.WinControls.Layouts.ContextLayoutManager.UpdateLayout()
    at Telerik.WinControls.RadElement.UpdateLayout()
    at Telerik.WinControls.UI.GridVisibilityHelper.EnsureRowVisible(GridViewRowInfo rowInfo)
    at Telerik.WinControls.UI.GridTableElement.EnsureRowVisible(GridViewRowInfo rowInfo)
    at Telerik.WinControls.UI.GridTableElement.EnsureCellVisible(GridViewRowInfo rowInfo, GridViewColumn column)
    at Telerik.WinControls.UI.GridTableElement.UpdateViewCore(Object sender, DataViewChangedEventArgs args)
    at Telerik.WinControls.UI.GridTableElement.UpdateView(Object sender, DataViewChangedEventArgs args)
    at Telerik.WinControls.UI.GridTableElement.ProcessTemplateEvent(GridViewEvent eventData)
    at Telerik.WinControls.UI.GridTableElement.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.RaiseCurrentChanged(GridViewTemplate template, GridViewRowInfo row, GridViewColumn column, Boolean user)
    at Telerik.WinControls.UI.GridViewTemplate.CollectionView_CurrentChanged(Object sender, EventArgs e)
    at System.EventHandler.Invoke(Object sender, EventArgs e)
    at Telerik.WinControls.Data.RadCollectionView`1.OnCurrentChanged(EventArgs args)
    at Telerik.WinControls.Data.RadCollectionView`1.SetCurrentPositionCore(Int32 newPosition, Boolean forceNotify, CurrentChangeReason reason)
    at Telerik.WinControls.Data.RadListSource`1.InitializeCurrentItem()
    at Telerik.WinControls.Data.RadListSource`1.Initialize()
    at Telerik.WinControls.Data.RadListSource`1.Bind(Object dataSource, String dataMember)
    at Telerik.WinControls.Data.RadListSource`1.set_DataSource(Object value)
    at Telerik.WinControls.UI.GridViewTemplate.set_DataSource(Object value)
    at Telerik.WinControls.UI.RadGridView.set_DataSource(Object value)
    at AgroCenterCommunity.LawsForm.UpdateData() in C:\Documents and Settings\mxL\My Documents\Visual Studio 2008\Projects\ACK_01\ACK_01\LawsForm.cs:line 245
    at AgroCenterCommunity.LawsForm.UpdateButton_Click(Object sender, EventArgs e) in C:\Documents and Settings\mxL\My Documents\Visual Studio 2008\Projects\ACK_01\ACK_01\LawsForm.cs:line 676
    at System.Windows.Forms.Control.OnClick(EventArgs e)
    at Telerik.WinControls.RadControl.OnClick(EventArgs e)
    at Telerik.WinControls.UI.RadButtonBase.buttonElement_Click(Object sender, EventArgs e)
    at Telerik.WinControls.RadItem.OnClick(EventArgs e)
    at Telerik.WinControls.UI.RadButtonItem.OnClick(EventArgs e)
    at Telerik.WinControls.UI.RadButtonElement.OnClick(EventArgs e)
    at Telerik.WinControls.RadItem.DoClick(EventArgs e)
    at Telerik.WinControls.RadItem.RaiseBubbleEvent(RadElement sender, RoutedEventArgs args)
    at Telerik.WinControls.RadElement.RaiseRoutedEvent(RadElement sender, RoutedEventArgs args)
    at Telerik.WinControls.RadItem.RaiseBubbleEvent(RadElement sender, RoutedEventArgs args)
    at Telerik.WinControls.RadElement.RaiseRoutedEvent(RadElement sender, RoutedEventArgs args)
    at Telerik.WinControls.RadElement.DoMouseUp(MouseEventArgs e)
    at Telerik.WinControls.ComponentInputBehavior.OnMouseUp(MouseEventArgs e)
    at Telerik.WinControls.RadControl.OnMouseUp(MouseEventArgs e)
    at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
    at System.Windows.Forms.Control.WndProc(Message& m)
    at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
    at Telerik.WinControls.RadControl.WndProc(Message& m)
    at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
    at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
    at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
    at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
    at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
    at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
    at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
    at System.Windows.Forms.Application.Run(Form mainForm)
    at AgroCenterCommunity.Program.SplashScreen() in C:\Documents and Settings\mxL\My Documents\Visual Studio 2008\Projects\ACK_01\ACK_01\Program.cs:line 41
    at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
    at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
    at System.Threading.ThreadHelper.ThreadStart()
    InnerException: System.NullReferenceException
    Message="Object reference not set to an instance of an object."
    Source="AgroCenterCommunity"
    StackTrace:
    at AgroCenterCommunity.LawsForm.CategoryView_ViewCellFormatting(Object sender, CellFormattingEventArgs e) in C:\Documents and Settings\mxL\My Documents\Visual Studio 2008\Projects\ACK_01\ACK_01\LawsForm.cs:line 360
    at Telerik.WinControls.UI.CellFormattingEventHandler.Invoke(Object sender, CellFormattingEventArgs e)
    at Telerik.WinControls.UI.RadGridViewElement.OnViewCellFormatting(Object sender, CellFormattingEventArgs e)
    at Telerik.WinControls.UI.GridDataCellElement.OnViewCellFormatting(CellFormattingEventArgs e)
    at Telerik.WinControls.UI.GridCellElement.UpdateInfo()
    at Telerik.WinControls.UI.GridVirtualizedCellElement.Initialize(GridViewColumn column, GridRowElement row)
    at Telerik.WinControls.UI.GridDataCellElement..ctor(GridViewColumn column, GridRowElement row)
    InnerException:

  2. MaxeL
    MaxeL avatar
    5 posts
    Member since:
    Aug 2012

    Posted 22 Dec 2012 Link to this post

    I add 

    this.CategoryView.Relations.Clear();
    this.CategoryView.MasterTemplate.SortDescriptors.Clear();
    in start of UdpateDate and

    Remove
    this.CategoryView.MasterTemplate.Reset();

    then i have trouble in this point:

    private void CategoryView_ViewCellFormatting(object sender, CellFormattingEventArgs e)
    {
    e.CellElement.DrawBorder = false;
    e.CellElement.DrawFill = true;
    GridDataCellElement dataCell = e.CellElement as GridDataCellElement;
    GridViewRowInfo row = e.Row;
      int par_id = Int32.Parse(row.Cells["parent_id"].Value.ToString()); // if this line is enabled i have "Exception has been thrown by the target of an invocation." in  "this.CategoryView.DataSource = source;"
    .....................
    ....................

  3. MaxeL
    MaxeL avatar
    5 posts
    Member since:
    Aug 2012

    Posted 22 Dec 2012 Link to this post

    if i trying get any value in CategoryView_ViewCellFormatting(object sender, CellFormattingEventArgs e)
    i have a proublem "Exception has been thrown by the target of an invocation." in "this.CategoryView.DataSource = source;"

    but, all cells values in my form display correctly. i have a DataSource, but i cannot get any value.
  4. MaxeL
    MaxeL avatar
    5 posts
    Member since:
    Aug 2012

    Posted 22 Dec 2012 Link to this post

    Last stacktrace:

    at System.RuntimeMethodHandle._InvokeConstructor(Object[] args, SignatureStruct& signature, IntPtr declaringType)
    at System.RuntimeMethodHandle.InvokeConstructor(Object[] args, SignatureStruct signature, RuntimeTypeHandle declaringType)
    at System.Reflection.RuntimeConstructorInfo.Invoke(BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
    at System.RuntimeType.CreateInstanceImpl(BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes)
    at System.Activator.CreateInstance(Type type, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes)
    at Telerik.WinControls.UI.GridRowElement.CreateCell(GridViewColumn column)
    at Telerik.WinControls.UI.CellElementProvider.CreateElement(GridViewColumn data, Object context)
    at Telerik.WinControls.UI.CellElementProvider.GetElement(GridViewColumn data, Object context)
    at Telerik.WinControls.UI.BaseVirtualizedContainer`1.UpdateElement(Int32 position, T data)
    at Telerik.WinControls.UI.BaseVirtualizedContainer`1.MeasureElements()
    at Telerik.WinControls.UI.BaseVirtualizedContainer`1.MeasureOverride(SizeF availableSize)
    at Telerik.WinControls.RadElement.MeasureCore(SizeF availableSize)
    at Telerik.WinControls.RadElement.Measure(SizeF availableSize)
    at Telerik.WinControls.UI.GridVirtualizedRowElement.MeasureElements(SizeF availableSize, SizeF clientSize, Padding borderThickness)
    at Telerik.WinControls.UI.LightVisualElement.MeasureOverride(SizeF availableSize)
    at Telerik.WinControls.UI.GridRowElement.MeasureOverride(SizeF availableSize)
    at Telerik.WinControls.RadElement.MeasureCore(SizeF availableSize)
    at Telerik.WinControls.RadElement.Measure(SizeF availableSize)
    at Telerik.WinControls.UI.VirtualizedStackContainer`1.MeasureElementCore(RadElement element, SizeF availableSize)
    at Telerik.WinControls.UI.ScrollableRowsContainerElement.MeasureElementCore(RadElement element, SizeF availableSize)
    at Telerik.WinControls.UI.VirtualizedStackContainer`1.MeasureElement(IVirtualizedElement`1 element)
    at Telerik.WinControls.UI.PinnedRowsContainerElement.MeasureElement(IVirtualizedElement`1 element)
    at Telerik.WinControls.UI.BaseVirtualizedContainer`1.MeasureElements()
    at Telerik.WinControls.UI.BaseVirtualizedContainer`1.MeasureOverride(SizeF availableSize)
    at Telerik.WinControls.UI.ScrollableRowsContainerElement.MeasureOverride(SizeF availableSize)
    at Telerik.WinControls.RadElement.MeasureCore(SizeF availableSize)
    at Telerik.WinControls.RadElement.Measure(SizeF availableSize)
    at Telerik.WinControls.UI.RowsContainerElement.MeasureOverride(SizeF availableSize)
    at Telerik.WinControls.RadElement.MeasureCore(SizeF availableSize)
    at Telerik.WinControls.RadElement.Measure(SizeF availableSize)
    at Telerik.WinControls.Layouts.ContextLayoutManager.UpdateLayout()
    at Telerik.WinControls.RadElement.UpdateLayout()
    at Telerik.WinControls.UI.GridVisibilityHelper.EnsureRowVisible(GridViewRowInfo rowInfo)
    at Telerik.WinControls.UI.GridTableElement.EnsureRowVisible(GridViewRowInfo rowInfo)
    at Telerik.WinControls.UI.GridTableElement.EnsureCellVisible(GridViewRowInfo rowInfo, GridViewColumn column)
    at Telerik.WinControls.UI.GridTableElement.UpdateViewCore(Object sender, DataViewChangedEventArgs args)
    at Telerik.WinControls.UI.GridTableElement.UpdateView(Object sender, DataViewChangedEventArgs args)
    at Telerik.WinControls.UI.GridTableElement.ProcessTemplateEvent(GridViewEvent eventData)
    at Telerik.WinControls.UI.GridTableElement.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.RaiseCurrentChanged(GridViewTemplate template, GridViewRowInfo row, GridViewColumn column, Boolean user)
    at Telerik.WinControls.UI.GridViewTemplate.EndCurrentRowUpdate(Boolean resumeService, Boolean update)
    at Telerik.WinControls.UI.GridViewTemplate.EndUpdate(Boolean notify, DataViewChangedEventArgs e)
    at Telerik.WinControls.UI.MasterGridViewTemplate.EndUpdate(Boolean notify, DataViewChangedEventArgs e)
    at Telerik.WinControls.UI.GridViewTemplate.EndDefer()
    at Telerik.WinControls.UI.GridViewTemplate.DeferHelper.Dispose()
    at AgroCenterCommunity.NewLawsForm.UpdateData() in C:\Documents and Settings\mxL\My Documents\Visual Studio 2008\Projects\ACK_01\ACK_01\NewLawsForm.cs:line 268
    at AgroCenterCommunity.NewLawsForm.NewLawsForm_Load(Object sender, EventArgs e) in C:\Documents and Settings\mxL\My Documents\Visual Studio 2008\Projects\ACK_01\ACK_01\NewLawsForm.cs:line 226
    at System.Windows.Forms.Form.OnLoad(EventArgs e)
    at System.Windows.Forms.Form.OnCreateControl()
    at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
    at System.Windows.Forms.Control.CreateControl()
    at System.Windows.Forms.Control.WmShowWindow(Message& m)
    at System.Windows.Forms.Control.WndProc(Message& m)
    at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
    at System.Windows.Forms.ContainerControl.WndProc(Message& m)
    at System.Windows.Forms.Form.WmShowWindow(Message& m)
    at System.Windows.Forms.Form.WndProc(Message& m)
    at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
    at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
    at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
    at System.Windows.Forms.UnsafeNativeMethods.IntCreateWindowEx(Int32 dwExStyle, String lpszClassName, String lpszWindowName, Int32 style, Int32 x, Int32 y, Int32 width, Int32 height, HandleRef hWndParent, HandleRef hMenu, HandleRef hInst, Object pvParam)
    at System.Windows.Forms.UnsafeNativeMethods.CreateWindowEx(Int32 dwExStyle, String lpszClassName, String lpszWindowName, Int32 style, Int32 x, Int32 y, Int32 width, Int32 height, HandleRef hWndParent, HandleRef hMenu, HandleRef hInst, Object pvParam)
    at System.Windows.Forms.NativeWindow.CreateHandle(CreateParams cp)
    at System.Windows.Forms.Control.CreateHandle()
    at System.Windows.Forms.Form.CreateHandle()
    at System.Windows.Forms.Control.get_Handle()
    at System.Windows.Forms.Form.SetVisibleCore(Boolean value)
    at System.Windows.Forms.Control.Show()
    at AgroCenterCommunity.MainMenu.LawsDocumentsButton_Click(Object sender, EventArgs e) in C:\Documents and Settings\mxL\My Documents\Visual Studio 2008\Projects\ACK_01\ACK_01\MainMenu.cs:line 493
    at System.Windows.Forms.Control.OnClick(EventArgs e)
    at Telerik.WinControls.RadControl.OnClick(EventArgs e)
    at Telerik.WinControls.UI.RadButtonBase.buttonElement_Click(Object sender, EventArgs e)
    at Telerik.WinControls.RadItem.OnClick(EventArgs e)
    at Telerik.WinControls.UI.RadButtonItem.OnClick(EventArgs e)
    at Telerik.WinControls.UI.RadButtonElement.OnClick(EventArgs e)
    at Telerik.WinControls.RadItem.DoClick(EventArgs e)
    at Telerik.WinControls.RadItem.RaiseBubbleEvent(RadElement sender, RoutedEventArgs args)
    at Telerik.WinControls.RadElement.RaiseRoutedEvent(RadElement sender, RoutedEventArgs args)
    at Telerik.WinControls.RadItem.RaiseBubbleEvent(RadElement sender, RoutedEventArgs args)
    at Telerik.WinControls.RadElement.RaiseRoutedEvent(RadElement sender, RoutedEventArgs args)
    at Telerik.WinControls.RadElement.DoMouseUp(MouseEventArgs e)
    at Telerik.WinControls.ComponentInputBehavior.OnMouseUp(MouseEventArgs e)
    at Telerik.WinControls.RadControl.OnMouseUp(MouseEventArgs e)
    at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
    at System.Windows.Forms.Control.WndProc(Message& m)
    at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
    at Telerik.WinControls.RadControl.WndProc(Message& m)
    at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
    at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
    at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
    at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
    at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
    at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
    at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
    at System.Windows.Forms.Application.Run(Form mainForm)
    at AgroCenterCommunity.Program.SplashScreen() in C:\Documents and Settings\mxL\My Documents\Visual Studio 2008\Projects\ACK_01\ACK_01\Program.cs:line 41
    at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
    at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
    at System.Threading.ThreadHelper.ThreadStart()
  5. MaxeL
    MaxeL avatar
    5 posts
    Member since:
    Aug 2012

    Posted 23 Dec 2012 Link to this post

    this is main problem:

    before changing datasource we need delete all relations!!!!!!!!!

    must be when datasource changes value, grid view trying to build hierarchy, but trying when old value is lost and new value is not set yet.

    correct code is:

    this.CategoryView.Relations.Clear();
    this.CategoryView.DataSource = CreateDataSource();
    this.CategoryView.Relations.AddSelfReference(this.CategoryView.MasterTemplate, "id", "parent_id");

    and!!!!
    in ViewCellFormatting:
    the same problem, value of DataSource not changed yet.

    if (dataCell.ExpanderItem != null)
    {
    dataCell.ExpanderItem.Expanded = true;
    }




    yeah...

    ps: sorry for my english

  6. Julian Benkov
    Admin
    Julian Benkov avatar
    1135 posts

    Posted 26 Dec 2012 Link to this post

    Hi MaxeL,

    Thank you for contacting us.

    I am glad to hear that you have solved your issue.

    Do not hesitate to contact us if you have further questions or issues. 

    Greetings,
    Julian Benkov
    the Telerik team
    Q3’12 of RadControls for WinForms is available for download (see what's new). Get it today.
  7. Ilya
    Ilya avatar
    7 posts
    Member since:
    Dec 2012

    Posted 05 Feb 2013 Link to this post

    That`s amazing! That is what i was looking for! Thx so much =) Clearing relations before changing datasource works so nice =)
Back to Top