Bug while filtering

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

    Posted 12 Oct 2009 Link to this post

    Hello

    I don't know if it's a bug or something in my code that's causing this, but I have a radgridview which I'm building in code behind from a collection retreive from a Webservice.

    I manually add every column I need with the types I need dynamically and then set the itemsource.

    The code works fine, but somehow, depending of the retreived data, when I try to filter a column, the page goes blank, and this error shows up :

    Erreur : Sys.InvalidOperationException: ManagedRuntimeError error #4004 in control 'ucSilverClient': System.InvalidOperationException: Aucun opérateur de forçage de type n'est défini entre les types 'System.String' et 'System.Int32'.
       à System.Linq.Expressions.Expression.GetUserDefinedCoercionOrThrow(ExpressionType coercionType, Expression expression, Type convertToType)
       à System.Linq.Expressions.Expression.Convert(Expression expression, Type type)
       à Telerik.Windows.Data.Expressions.FilterDescriptorExpressionBuilder.CreateMemberExpression()
       à Telerik.Windows.Data.Expressions.FilterDescriptorExpressionBuilder.CreateBodyExpression()
       à Telerik.Windows.Data.FilterDescriptor.CreateFilterExpression(ParameterExpression parameterExpression)
       à Telerik.Windows.Data.FilterDescriptorBase.CreateFilterExpression(Expression instance)
       à Telerik.Windows.Data.Expressions.FilterDescriptorCollectionExpressionBuilder.CreateBodyExpression()
       à Telerik.Windows.Data.CompositeFilterDescriptor.CreateFilterExpression(ParameterExpression parameterExpression)
       à Telerik.Windows.Data.FilterDescriptorBase.CreateFilterExpression(Expression instance)
       à Telerik.Windows.Data.Expressions.FilterDescriptorCollectionExpressionBuilder.CreateBodyExpression()
       à Telerik.Windows.Data.Expressions.FilterExpressionBuilder.CreateFilterExpression()
       à Telerik.Windows.Data.FilterDescriptorCollection.CreateFilterExpression(Type itemType)
       à Telerik.Windows.Data.QueryableExtensions.Where(IQueryable source, FilterDescriptorCollection filterDescriptors)
       à Telerik.Windows.Data.QueryableCollectionView.CreateView()
       à Telerik.Windows.Data.QueryableCollectionView.get_QueryableView()
       à Telerik.Windows.Data.QueryableCollectionView.CreateInternalList()
       à Telerik.Windows.Data.QueryableCollectionView.get_InternalList()
       à Telerik.Windows.Data.QueryableCollectionView.GetEnumerator()
       à Telerik.Windows.Data.RecordFactory.<CreateRecordsForGroupRecord>d__0.MoveNext()
       à System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
       à System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
       à Telerik.Windows.Controls.GridView.GridViewDataControl.PopulateRecords()
       à Telerik.Windows.Controls.GridView.GridViewDataControl.LoadData()
       à Telerik.Windows.Controls.GridView.GridViewDataControl.OnCollectionViewCollectionChanged(Object sender, NotifyCollectionChangedEventArgs e)
       à 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.RefreshOrDefer()
       à Telerik.Windows.Data.QueryableCollectionView.OnFilterDescriptorsItemChanged(Object sender, ItemChangedEventArgs`1 e)
       à Telerik.Windows.Data.ObservableItemCollection`1.OnItemChanged(ItemChangedEventArgs`1 e)
       à Telerik.Windows.Data.ObservableItemCollection`1.OnItemPropertyChanged(Object sender, PropertyChangedEventArgs e)
       à System.ComponentModel.PropertyChangedEventHandler.Invoke(Object sender, PropertyChangedEventArgs e)
       à Telerik.Windows.Data.FilterDescriptorBase.OnPropertyChanged(PropertyChangedEventArgs args)
       à Telerik.Windows.Data.FilterDescriptorBase.OnPropertyChanged(String propertyName)
       à Telerik.Windows.Data.CompositeFilterDescriptor.OnFilterDescriptorsCollectionChanged(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.InsertItem(Int32 index, T item)
       à Telerik.Windows.Data.RadObservableCollection`1.InsertItem(Int32 index, T item)
       à Telerik.Windows.Data.ObservableItemCollection`1.InsertItem(Int32 index, T item)
       à System.Collections.ObjectModel.Collection`1.Add(T item)
       à Telerik.Windows.Data.RadObservableCollection`1.AddRange(IEnumerable`1 items)
       à Telerik.Windows.Controls.GridView.FilteringDropDown.DistinctValuesListSelectionChanged(Object sender, SelectionChangedEventArgs e)
    Fichier Source : http://reference-nouveau.t2j.fr/ScriptResource.axd?d=Og6YsfpuTjnPEqbkVzgbSnTEayfIQjBzbmSj4NAjZKF1N_7FGO7N4k0p9zwPFq6OiHfWKz6Jo3PkAJXR4RdjkQ2&t=7a9b7a9d
    Ligne : 461

    I hope that you can help me sort this out, cause I have no clue on what's causing this. I'm thinking, based on the stacktrace, that it's some kind of cast problem, but I can't be sure.


  2. Stefan Dobrev
    Admin
    Stefan Dobrev avatar
    790 posts

    Posted 13 Oct 2009 Link to this post

    Hello Subileau,

    It seems that you are setting the wrong DataType on your column. For example if you have a Customer object with Name(string) and Age(In32) properties you should create two GridViewDataColumns like this:
    this.RadGridView.Columns.Add(new GridViewDataColumn { DataMemberBinding = new Binding("Name"), DataType = typeof(string) });
    this.RadGridView.Columns.Add(new GridViewDataColumn { DataMemberBinding = new Binding("Age"), DataType = typeof(int) });

    Is this the case? If not can you please send us a sample project so that we can debug this problem locally.

    Greetings,
    Stefan Dobrev
    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
  4. Ludovic Gerbault
    Ludovic Gerbault avatar
    226 posts
    Member since:
    Apr 2009

    Posted 13 Oct 2009 Link to this post

    Thanks, I solved earlier this afternoon.

    As I was saying, I was creating the columns manually, and setting their datatypes according to the data my webservice gave me.

    Those data were actually wrong, most of the columns were set with an integer type, that was the source of the problem. So my code was working fine, just the parameters were wrong.
Back to Top