Silverlight crashed while deleting item from RadGridView

4 posts, 0 answers
  1. George
    George avatar
    3 posts
    Member since:
    Oct 2011

    Posted 10 Oct 2011 Link to this post

    Hi, while writing a simple master-details demo (http://dl.dropbox.com/u/12503247/Chinook.zip), I am in trouble.

    First I press INSERT to insert a new row, type some letter as Album title.
    And then I press DELETE to delete this row from RadGridView, IE crashed, And I got following exception info:

    SCRIPT5022: Unhandled Error in Silverlight Application
    Code: 4004    
    Category: ManagedRuntimeError       
    Message: System.InvalidOperationException: The specified entity is not a member of this collection.
       at System.ServiceModel.DomainServices.Client.EntitySet.Remove(Entity entity)
       at System.ServiceModel.DomainServices.Client.EntityCollection`1.ListCollectionViewProxy`1.Remove(Object value)
       at System.ServiceModel.DomainServices.Client.EntityCollection`1.ListCollectionViewProxy`1.RemoveAt(Int32 index)
       at System.Windows.Data.ListCollectionView.RemoveAt(Int32 index)
       at System.Windows.Data.ListCollectionView.Remove(Object item)
       at Telerik.Windows.Data.DataItemCollection.Remove(Object item)
       at Telerik.Windows.Controls.GridView.GridViewDataControl.DeleteItems(IEnumerable`1 itemsToDelete)
       at Telerik.Windows.Controls.GridView.GridViewDataControl.DeleteSelectedItems()
       at Telerik.Windows.Controls.GridView.GridViewDataControl.TryDeleteSelectedItems()
       at Telerik.Windows.Controls.GridView.GridViewDataControl.OnDeleteCommand(Object sender, ExecutedRoutedEventArgs e)
       at Telerik.Windows.Controls.CommandBinding.OnExecuted(Object sender, ExecutedRoutedEventArgs e)
       at Telerik.Windows.Controls.CommandManager.ExecuteCommandBinding(Object sender, ExecutedRoutedEventArgs e, CommandBinding commandBinding)
       at Telerik.Windows.Controls.CommandManager.FindCommandBinding(CommandBindingCollection commandBindings, Object sender, RoutedEventArgs e, ICommand command, Boolean execute)
       at Telerik.Windows.Controls.CommandManager.FindCommandBinding(Object sender, RoutedEventArgs e, ICommand command, Boolean execute)
       at Telerik.Windows.Controls.CommandManager.OnExecuted(Object sender, ExecutedRoutedEventArgs e)
       at Telerik.Windows.Controls.ExecutedRoutedEventArgs.InvokeEventHandler(Delegate genericHandler, Object target)
       at Telerik.Windows.RadRoutedEventArgs.InvokeHandler(Delegate handler, Object target)
       at Telerik.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RadRoutedEventArgs routedEventArgs)
       at Telerik.Windows.RouteItem.InvokeHandler(RadRoutedEventArgs routedEventArgs)
       at Telerik.Windows.EventRoute.InvokeHandlersImpl(Object source, RadRoutedEventArgs args, Boolean raisedAgain)
       at Telerik.Windows.EventRoute.InvokeHandlers(Object source, RadRoutedEventArgs args)
       at Telerik.Windows.RadRoutedEventHelper.RaiseEvent(DependencyObject element, RadRoutedEventArgs args)
       at Telerik.Windows.DependencyObjectExtensions.RaiseEvent(DependencyObject element, RadRoutedEventArgs e)
       at Telerik.Windows.Controls.RoutedCommand.ExecuteImpl(Object parameter, UIElement target)
       at Telerik.Windows.Controls.RoutedCommand.Execute(Object parameter, UIElement target)
       at Telerik.Windows.Controls.GridView.GridViewDataControl.ExecutePendingCommand()
       at Telerik.Windows.Controls.GridView.GridViewDataControl.PendAndExecuteCommands(KeyEventArgs e)
       at Telerik.Windows.Controls.GridView.GridViewDataControl.OnKeyDown(KeyEventArgs e)
       at System.Windows.Controls.Control.OnKeyDown(Control ctrl, EventArgs e)
       at MS.Internal.JoltHelper.FireEvent(IntPtr unmanagedObj, IntPtr unmanagedObjArgs, Int32 argsTypeIndex, Int32 actualArgsTypeIndex, String eventName)     
     
    ChinookTestPage.aspx, Line:56 Char:13

    If I removed CompositionAttribute from property Albums in class ArtistMetadata, everything works fine. 

    Is there anybody have same problem? How can I avoid it if I really do not want client to insert/delete albums entity without a artist?

    The demo use latest Chinook Database for MSSQL and Silverlight 4. Telerik Controls version is RadControls for Silverlight Q2 2011 SP1.  

    Thanks, best regards.

    George.P
  2. George
    George avatar
    3 posts
    Member since:
    Oct 2011

    Posted 12 Oct 2011 Link to this post

    It's seems a bug in class EntityCollection, here is my debug details: http://forums.silverlight.net/t/240836.aspx/1?Possible+bug+in+EntityCollection+T+ .

    The WCF RIA Services V1.0 SP2 RC still have this problem. Is there a way to bind an EntityCollection with an ObservableCollection, so that we can avoid this bug?
  3. Nedyalko Nikolov
    Admin
    Nedyalko Nikolov avatar
    871 posts

    Posted 13 Oct 2011 Link to this post

    Hi George,

    There is no way to "bind" collections you will need a proxy collection. However Telerik has the right solution for you. I would recommend using of RadDomainDataSource control which in fact does similar "binding" between EntityCollection and ObservableCollection. We've just test your scenario with RadDomainDataSource and RadGridView and everything works fine. For more information about RadDomainDataSource control you can take a look at this blog post (and referenced blog posts).

    Best wishes,
    Nedyalko Nikolov
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

  4. George
    George avatar
    3 posts
    Member since:
    Oct 2011

    Posted 14 Oct 2011 Link to this post

    We have a lot of pages which have RadGridView control binding to EntityCollection, it cost too much to change current business logic with DomainDataSource control.

    To someone who have same problem, our not good but worked solution is handle GridView deleting event, manually delete detail entity from master entity.

    Thank you for reply.
Back to Top