Data Platform Developer Center >
Data Platform Development Forums
>
WCF Data Services (formerly known as ADO.NET Data Services)
>
Cant update CollectionView based on ADO.Net Data Service
Cant update CollectionView based on ADO.Net Data Service
- I am using VS2010 beta 2 and have a solution with two projects. My "Data Service" project exposes a ADO.Net Data Service hooked up to an Entity Data Model:
My "WPC Client" project has a service reference to the Data Service above. A data grid is bound to the data service:public class RoadmapperDataService : DataService<RoadmapperModelEntityContainer> { public static void InitializeService(DataServiceConfiguration config) { config.SetEntitySetAccessRule("*", EntitySetRights.All); } }
and the code behind for the WPF window hosting this data grid:<Window.Resources> <CollectionViewSource x:Key="roadmapsViewSource" d:DesignSource="{d:DesignInstance my:Roadmaps, CreateList=True}" /> </Window.Resources> <Grid DataContext="{StaticResource roadmapsViewSource}"> <DataGrid AutoGenerateColumns="False" EnableRowVirtualization="True" Height="200" HorizontalAlignment="Left" ItemsSource="{Binding Mode=TwoWay}" Margin="12,12,0,0" Name="roadmapsDataGrid" RowDetailsVisibilityMode="VisibleWhenSelected" VerticalAlignment="Top" Width="400"> <DataGrid.Columns> <DataGridTextColumn x:Name="roadmapIDColumn" Binding="{Binding Path=RoadmapID}" Header="Roadmap ID" Width="SizeToHeader" /> <DataGridTextColumn x:Name="roadmapNameColumn" Binding="{Binding Path=RoadmapName, Mode=TwoWay}" Header="Roadmap Name" Width="SizeToHeader" /> </DataGrid.Columns> </DataGrid> </Grid>
The window loads OK and displays data from the data service at runtime. However when I try to edit any data in the data grid I get an exception thrown: EditItem' is not allowed for this view.public partial class MainWindow : Window { private Uri svcUri; private RoadmapperModelEntityContainer context; public MainWindow() { svcUri = new Uri("http://localhost:10000/RoadmapperDataService.svc"); context = new RoadmapperModelEntityContainer(svcUri); InitializeComponent(); } private void Window_Loaded(object sender, RoutedEventArgs e) { System.Windows.Data.CollectionViewSource roadmapsViewSource = ((System.Windows.Data.CollectionViewSource)(this.FindResource("roadmapsViewSource"))); roadmapsViewSource.Source = context.Roadmaps; } }
Can anyone assist? I have searched and searched for the answer to this one :-(
Answers
- Hi,
The issue is that the Source property of the CollectionViewSource is being set to the DataServiceQuery type which only supports the IEnumerable interface and not the other interfaces required for Databinding to work.
If you want binding support for UI controls in WPF or Silverlight applications , please look at the Databinding support we introduced in our latest CTP .
Introduction to Data Binding in Silverlight 3 with CTP2
Phani Raj Astoria http://blogs.msdn.com/PhaniRaj- Marked As Answer byPratik Patel - MSFTModeratorTuesday, November 03, 2009 11:56 PM
All Replies
- Do you have a callstack for the exception (or at least its type)?
Are you using views in your database?
If this error comes from the server could you please capture the response the server sends? (for example using Fiddler or something similar).
Thanks,
Vitek Karas [MSFT] - Hi,
The issue is that the Source property of the CollectionViewSource is being set to the DataServiceQuery type which only supports the IEnumerable interface and not the other interfaces required for Databinding to work.
If you want binding support for UI controls in WPF or Silverlight applications , please look at the Databinding support we introduced in our latest CTP .
Introduction to Data Binding in Silverlight 3 with CTP2
Phani Raj Astoria http://blogs.msdn.com/PhaniRaj- Marked As Answer byPratik Patel - MSFTModeratorTuesday, November 03, 2009 11:56 PM


