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

Binding Grid to RIA Service

5 Answers 164 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Terry
Top achievements
Rank 1
Terry asked on 10 Mar 2010, 02:05 AM
Hi:

I'm trying to bind a grid to specific columns from a LINQ select.

The following works:
                Report_Grid.ItemsSource =  
                    from z in kdc.entity_ColumnNamesForViews  
                    where z.ColumnNo <= 10  
                    select z;  
 
but the following does not work:
                Report_Grid.ItemsSource =  
                    from z in kdc.entity_ColumnNamesForViews  
                    where z.ColumnNo <= 10  
                    select new { Number = z.ColumnNo, Name = z.ColumnName };  
 
I get the following error:
System.MethodAccessException was unhandled by user code
  Message=Attempt by method 'System.Linq.EnumerableQuery.Create(System.Type, System.Collections.IEnumerable)' to access method 'System.Linq.EnumerableQuery`1<System.__Canon>..ctor(System.Collections.Generic.IEnumerable`1<System.__Canon>)' failed.
  StackTrace:
       at System.RuntimeMethodHandle.PerformSecurityCheck(Object obj, RuntimeMethodHandleInternal method, RuntimeType parent, UInt32 invocationFlags)
       at System.RuntimeMethodHandle.PerformSecurityCheck(Object obj, IRuntimeMethodInfo method, RuntimeType parent, UInt32 invocationFlags)
       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 System.Activator.CreateInstance(Type type, Object[] args)
       at System.Linq.EnumerableQuery.Create(Type elementType, IEnumerable sequence)
       at System.Linq.Queryable.AsQueryable(IEnumerable source)
       at Telerik.Windows.Data.QueryableFactory.CreateQueryable(IEnumerable source)
       at Telerik.Windows.Data.QueryableCollectionView..ctor(IEnumerable sourceCollection)
       at Telerik.Windows.Data.DataItemCollection.CreateCollectionView(IEnumerable source)
       at Telerik.Windows.Data.DataItemCollection.SetItemsSource(IEnumerable source)
       at Telerik.Windows.Controls.GridView.GridViewDataControl.<>c__DisplayClass44.<Bind>b__43()
       at Telerik.Windows.Controls.CursorManager.PerformTimeConsumingOperation(FrameworkElement frameworkElement, Action action)
       at Telerik.Windows.Controls.GridView.GridViewDataControl.Bind(Object newValue)
       at Telerik.Windows.Controls.GridView.GridViewDataControl.OnItemsSourceChanged(Object oldValue, Object newValue)
       at Telerik.Windows.Controls.DataControl.OnItemsSourcePropertyChanged(DependencyObject origin, DependencyPropertyChangedEventArgs args)
       at Telerik.Windows.PropertyMetadata.<>c__DisplayClass1.<Create>b__0(DependencyObject d, DependencyPropertyChangedEventArgs e)
       at System.Windows.DependencyObject.RaisePropertyChangeNotifications(DependencyProperty dp, Object oldValue, Object newValue)
       at System.Windows.DependencyObject.UpdateEffectiveValue(DependencyProperty property, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, ValueOperation operation)
       at System.Windows.DependencyObject.SetValueInternal(DependencyProperty dp, Object value, Boolean allowReadOnlySet)
       at System.Windows.DependencyObject.SetValue(DependencyProperty dp, Object value)
       at Telerik.Windows.Controls.DataControl.set_ItemsSource(Object value)
       at HCDA4.ReportGrid.Data_Columns_Ready(Object sender, EventArgs e)
       at System.Windows.Ria.OperationBase.Complete(Object result)
       at System.Windows.Ria.LoadOperation.Complete(DomainClientResult result)
       at System.Windows.Ria.DomainContext.CompleteLoad(IAsyncResult asyncResult)
       at System.Windows.Ria.DomainContext.<>c__DisplayClass17.<Load>b__13(Object )
  InnerException:



5 Answers, 1 is accepted

Sort by
0
Vlad
Telerik team
answered on 10 Mar 2010, 08:31 AM
Hi Terry,

Binding to anonymous types in Silverlight is not supported currently due to the fact that these types are internal - you can check this post for more info.

Kind regards,
Vlad
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Terry
Top achievements
Rank 1
answered on 10 Mar 2010, 08:14 PM
Thanks for the quick response.

So it sounds like binding based on any class not known at compile time is totally impossible in Silverlight?

I'm working with a business intelligence system where users can add new columns to views they look at every day.  I was hoping that I could devise a system where a programmer would not have to update the EF model and do a new build to accomodate these changes.  my scheme was to pass back the column names and types in one query, then pass back the column values formatted as strings with generic names col01, col02, etc.  Then on the client I would rename the columns in dynamic LINQ, and bind to the resulting object.  But of course the object I create will be anonymous, so it sounds like this is impossible.  Any time a user on the web revises a view, the changes won't appear until the application is rebuilt.

Is that correct?  If so, we need to find a radically different way of doing this.

Thanks,

Terry
0
Vlad
Telerik team
answered on 11 Mar 2010, 08:07 AM
Hello Terry,

You can check my DataTable if you want dynamic objects binding in Silverlight.

Best wishes,
Vlad
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Afamefuna
Top achievements
Rank 1
answered on 06 Jun 2012, 10:29 PM
Good day,

I am having a similar issue.

I am using the telerik control suite that comes with Dotnetnuke 6.1. Everything works great on my local development machine, but when I upload to godaddy.com, I get the following error while trying to load a page that displays information from a radgrid

A critical error has occurred. Attempt by method 'Telerik.Web.UI.GridDataTableFromEnumerable.ToGenericEnumerable(System.Collections.IEnumerable, Telerik.Web.UI.GridTableView)' to access method 'Telerik.Web.UI.GridDataTableFromEnumerable+GridGenericEnumerable`1<System.__Canon>..ctor(System.Collections.IEnumerable)' failed.

Please Please, Is there any solution to this?

Regards,
Afam
0
Vlad
Telerik team
answered on 07 Jun 2012, 05:25 AM
Hi,

 This is not related to RadGridView for Silverlight!

Please post your question in the relevant forum category.

Kind regards,
Vlad
the Telerik team

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

Tags
GridView
Asked by
Terry
Top achievements
Rank 1
Answers by
Vlad
Telerik team
Terry
Top achievements
Rank 1
Afamefuna
Top achievements
Rank 1
Share this question
or