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

Problem in adding a new row

2 Answers 136 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Reeta
Top achievements
Rank 1
Reeta asked on 19 May 2009, 12:08 PM
I had a grid view which contains a template column and other columns are autogenerated. I found that "AddingNewDataItem" event is fired when i press insert when the grid view is focused. but it gives me an exception that

Exception has been thrown by the target of an invocation.

System.Reflection.TargetInvocationException was unhandled
  Message="Exception has been thrown by the target of an invocation."
  Source="mscorlib"
  StackTrace:
       at System.RuntimeMethodHandle._InvokeMethodFast(Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)
       at System.RuntimeMethodHandle.InvokeMethodFast(Object target, Object[] arguments, Signature sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)
       at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks)
       at System.Delegate.DynamicInvokeImpl(Object[] args)
       at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Boolean isSingleParameter)
       at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Boolean isSingleParameter, Delegate catchHandler)
       at System.Windows.Threading.Dispatcher.WrappedInvoke(Delegate callback, Object args, Boolean isSingleParameter, Delegate catchHandler)
       at System.Windows.Threading.DispatcherOperation.InvokeImpl()
       at System.Windows.Threading.DispatcherOperation.InvokeInSecurityContext(Object state)
       at System.Threading.ExecutionContext.runTryCode(Object userData)
       at System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData)
       at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Windows.Threading.DispatcherOperation.Invoke()
       at System.Windows.Threading.Dispatcher.ProcessQueue()
       at System.Windows.Threading.Dispatcher.WndProcHook(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
       at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
       at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
       at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Boolean isSingleParameter)
       at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Boolean isSingleParameter, Delegate catchHandler)
       at System.Windows.Threading.Dispatcher.WrappedInvoke(Delegate callback, Object args, Boolean isSingleParameter, Delegate catchHandler)
       at System.Windows.Threading.Dispatcher.InvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Boolean isSingleParameter)
       at System.Windows.Threading.Dispatcher.Invoke(DispatcherPriority priority, Delegate method, Object arg)
       at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
       at MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)
       at System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)
       at System.Windows.Threading.Dispatcher.PushFrame(DispatcherFrame frame)
       at System.Windows.Threading.Dispatcher.Run()
       at System.Windows.Application.RunDispatcher(Object ignore)
       at System.Windows.Application.RunInternal(Window window)
       at System.Windows.Application.Run(Window window)
       at System.Windows.Application.Run()
       at Cerebrata.CloudStorage.UI.WPF.App.Main() in D:\Projects\CerebrataCloudStorage\UI.WPF\obj\Debug\App.g.cs:line 0
       at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
       at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
       at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       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="Telerik.Windows.Controls.GridView"
       StackTrace:
            at Telerik.Windows.Controls.GridView.GridViewCell.ShowEditor() in c:\Builds\WPF_Scrum\X1_Q1_2009\Sources\Development\WPF\GridView\GridView\Cells\GridViewCell.cs:line 488
            at Telerik.Windows.Controls.GridView.GridViewCell.<ToggleEditor>b__0() in c:\Builds\WPF_Scrum\X1_Q1_2009\Sources\Development\WPF\GridView\GridView\Cells\GridViewCell.cs:line 593
            at Telerik.Windows.Controls.GridView.GridViewCell.ModifyCellTemplate(Action executeAction) in c:\Builds\WPF_Scrum\X1_Q1_2009\Sources\Development\WPF\GridView\GridView\Cells\GridViewCell.cs:line 461
            at Telerik.Windows.Controls.GridView.GridViewCell.ToggleEditor() in c:\Builds\WPF_Scrum\X1_Q1_2009\Sources\Development\WPF\GridView\GridView\Cells\GridViewCell.cs:line 593
            at Telerik.Windows.Controls.GridView.EditContext.OnCellEditModeChanged(GridViewCell cell, Boolean newIsInEditMode) in c:\Builds\WPF_Scrum\X1_Q1_2009\Sources\Development\WPF\GridView\GridView\Editing\EditContext.cs:line 231
            at Telerik.Windows.Controls.GridView.GridViewCell.IsInEditModeChanged(DependencyObject target, DependencyPropertyChangedEventArgs e) in c:\Builds\WPF_Scrum\X1_Q1_2009\Sources\Development\WPF\GridView\GridView\Cells\GridViewCell.cs:line 586
            at System.Windows.DependencyObject.OnPropertyChanged(DependencyPropertyChangedEventArgs e)
            at System.Windows.FrameworkElement.OnPropertyChanged(DependencyPropertyChangedEventArgs e)
            at System.Windows.DependencyObject.NotifyPropertyChange(DependencyPropertyChangedEventArgs args)
            at System.Windows.DependencyObject.UpdateEffectiveValue(EntryIndex entryIndex, DependencyProperty dp, PropertyMetadata metadata, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, Boolean coerceWithDeferredReference, OperationType operationType)
            at System.Windows.DependencyObject.SetValueCommon(DependencyProperty dp, Object value, PropertyMetadata metadata, Boolean coerceWithDeferredReference, OperationType operationType, Boolean isInternal)
            at System.Windows.DependencyObject.SetValue(DependencyProperty dp, Object value)
            at Telerik.Windows.Controls.GridView.GridViewCell.set_IsInEditMode(Boolean value) in c:\Builds\WPF_Scrum\X1_Q1_2009\Sources\Development\WPF\GridView\GridView\Cells\GridViewCell.cs:line 214
            at Telerik.Windows.Controls.GridView.EditContext.SwitchCellToEditMode(GridViewCell cell) in c:\Builds\WPF_Scrum\X1_Q1_2009\Sources\Development\WPF\GridView\GridView\Editing\EditContext.cs:line 243
            at Telerik.Windows.Controls.GridView.EditContext.BeginEdit(GridViewCell gridViewCell) in c:\Builds\WPF_Scrum\X1_Q1_2009\Sources\Development\WPF\GridView\GridView\Editing\EditContext.cs:line 259
       InnerException:


2 Answers, 1 is accepted

Sort by
0
Reeta
Top achievements
Rank 1
answered on 20 May 2009, 05:35 AM
I made the template column read only and it works for me. But now i had another problem that on "AddingNewDataItem" event i made a new DataRowView and set e.NewObject like this

                DataRowView dv  = myDataTable.DefaultView.AddNew();
                dv["IsMarkForDelete"] = false;
                dv["TimeStamp"] = DateTime.Now;
                e.NewObject = dv;

now it insert 2 rows in the data grid with same values one of them is in editable mode. And when i click on another row the extra row is removed. But if i call commitEdit()  then both rows are there.

0
Nedyalko Nikolov
Telerik team
answered on 22 May 2009, 12:01 PM
Hello Reeta,

It seems that you've hit a known issue with the 2009_Q1_SP1 release, which is already fixed.
Service pack 2 will be available on Monday next week.
Sorry for the inconvenience caused.

Best wishes,
Nedyalko Nikolov
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
GridView
Asked by
Reeta
Top achievements
Rank 1
Answers by
Reeta
Top achievements
Rank 1
Nedyalko Nikolov
Telerik team
Share this question
or