Filtering on Int or Double values crashes the application

2 posts, 0 answers
  1. Ludovic Gerbault
    Ludovic Gerbault avatar
    226 posts
    Member since:
    Apr 2009

    Posted 17 Dec 2009 Link to this post

    Hi Guys

    I seem to be having troubles with the filtering function.

    I have a very simple grid, I create manually its columns, and bind them programatically to a IList<MyClass> object retreive from WCF.
    So far so good.

    I've added a function on the filtered event, so that I can perform some logic related to the ChartAggregateGrouping.

    If the member is a string, no issue, but if it is an int or a double value, the application turns blank

    Here's the stacktrace

    Erreur : Unhandled Error in Silverlight Application Impossible d'effectuer un cast de l'objet de type 'System.Int32' en type 'System.String'.   à lambda_method(ExecutionScope , GridBO )
       à System.Linq.Enumerable.WhereListIterator`1.MoveNext()
       à System.Linq.Buffer`1..ctor(IEnumerable`1 source)
       à System.Linq.OrderedEnumerable`1.<GetEnumerator>d__0.MoveNext()
       à Telerik.Windows.Data.QueryableCollectionView.PopulateInternalList(IQueryable view)
       à Telerik.Windows.Data.QueryableCollectionView.CreateInternalList()
       à Telerik.Windows.Data.QueryableCollectionView.EnsureInternalList()
       à Telerik.Windows.Data.QueryableCollectionView.get_InternalList()
       à Telerik.Windows.Data.QueryableCollectionView.get_IsEmpty()
       à Telerik.Windows.Controls.GridView.BaseItemsControl.OnItemCollectionChanged(Object sender, NotifyCollectionChangedEventArgs e)
       à System.Collections.Specialized.NotifyCollectionChangedEventHandler.Invoke(Object sender, NotifyCollectionChangedEventArgs e)
       à Telerik.Windows.Data.DataItemCollection.OnCollectionChanged(NotifyCollectionChangedEventArgs e)
       à Telerik.Windows.Data.DataItemCollection.Telerik.Windows.Data.IWeakEventListener<System.Collections.Specialized.NotifyCollectionChangedEventArgs>.ReceiveWeakEvent(Object sender, NotifyCollectionChangedEventArgs e)
       à Telerik.Windows.Data.WeakEvent.WeakListener`1.Handler(Object sender, TArgs args)
       à System.Collections.Specialized.NotifyCollectionChangedEventHandler.Invoke(Object sender, NotifyCollectionChangedEventArgs e)
       à Telerik.Windows.Data.QueryableCollectionView.OnCollectionChanged(NotifyCollectionChangedEventArgs args)
       à Telerik.Windows.Data.QueryableCollectionView.RefreshAndRaiseCollectionChanged(NotifyCollectionChangedEventArgs args)
       à Telerik.Windows.Data.QueryableCollectionView.Refresh()
       à Telerik.Windows.Data.QueryableCollectionView.EndDefer()
       à Telerik.Windows.Data.QueryableCollectionView.DeferHelper.Dispose()
       à Telerik.Windows.Data.DataItemCollection.OnGroupDescriptorsCollectionChanged(Object sender, NotifyCollectionChangedEventArgs e)
       à System.Collections.Specialized.NotifyCollectionChangedEventHandler.Invoke(Object sender, NotifyCollectionChangedEventArgs e)
       à System.Collections.ObjectModel.ObservableCollection`1.OnCollectionChanged(NotifyCollectionChangedEventArgs e)
       à Telerik.Windows.Data.RadObservableCollection`1.OnCollectionChanged(NotifyCollectionChangedEventArgs e)
       à System.Collections.ObjectModel.ObservableCollection`1.RemoveItem(Int32 index)
       à Telerik.Windows.Data.RadObservableCollection`1.RemoveItem(Int32 index)
       à Telerik.Windows.Data.ObservableItemCollection`1.RemoveItem(Int32 index)
       à System.Collections.ObjectModel.Collection`1.Remove(T item)
       à Telerik.Windows.Controls.GridView.GridViewDataControl.Ungroup(String member)
       à Telerik.Windows.Controls.GridView.GridViewDataControl.<>c__DisplayClass2d.<GroupingRequested>b__2c()
       à Telerik.Windows.Controls.CursorManager.PerformTimeConsumingOperation(FrameworkElement frameworkElement, Action action)
       à Telerik.Windows.Controls.GridView.GridViewDataControl.GroupingRequested(Object origin, GroupingRequestedEventArgs e)
    Fichier Source : http://localhost:49232/Default.aspx
    Ligne : 0

    And there's the class definition :

    public class ChartCollection1 
        { 
            private String Attraa; 
            private String Attrab; 
            private String Attrac; 
            private String Attrad; 
     
            public int attraa 
            {  
                get 
                { 
                    return Convert.ToInt32(Attraa.ToString()); 
                } 
                set 
                { 
                    Attraa = value.ToString(); 
                } 
            } 
     
            public String attrab 
            { 
                get 
                { 
                    return Attrab; 
                } 
                set 
                { 
                    Attrab = value.ToString(); 
                } 
            } 
     
            public String attrac 
            { 
                get 
                { 
                    return Attrac; 
                } 
                set 
                { 
                    Attrac = value.ToString(); 
                } 
            } 
     
            public Double attrad 
            { 
                get 
                { 
                    return Convert.ToDouble(Attrad.ToString()); 
                } 
                set 
                { 
                    Attrad = value.ToString(); 
                } 
            } 
     
            public ChartCollection1(GridBO result) 
            { 
                this.Attraa = result.attraa.ToString(); 
                this.attrab = result.attrab.ToString(); 
                this.attrac = result.attrac.ToString(); 
                this.Attrad = result.attrad.ToString(); 
            } 
        } 

    Apparently, there's an Int to string cast error somewhere, but not in my own code, since the filtered event isn't being launched at all.



  2. Rossen Hristov
    Admin
    Rossen Hristov avatar
    2478 posts

    Posted 18 Dec 2009 Link to this post

    Hi Subileau Pascal,

    Unfortunately, you forgot to tell us the most important part. What are you doing in the filtered event handler? It seems that the logic you have added to the filtered event handler is causing the exception. So what is it?

    I have created and attached a sample project with the information you have provided and it works without any errors. The Filtered event is raised no matter which column I filter on.

    Please modify the sample project so that it reproduces the exception and send it back to us. We will then take a look at your code and tell you what the problem is.

    Regards,
    Ross
    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.
  3. DevCraft banner
Back to Top