CRUD operation on Linq query in DataGrid

Nov 22, 2009 at 10:37 AM


I have a simple query in linq

var query = from p in db.Products select new { p.Name, p.Unit, p.Rate, p.Opening, p.Status };

dataGrid.ItemsSource = query.ToList();

I am unable to perform CRUD operation in datagrid.

Datagrid is showing the query result but i am unable to change the data.

Here is the code for data grid in xaml

<dg:DataGrid Name="dataGrid" AutoGenerateColumns="True" CanUserAddRows="True" ItemsSource="{Binding}" CanUserDeleteRows="True" IsReadOnly="False">


Jan 4, 2010 at 10:10 PM

HAve you set the context?


db= new db();
uiDgCustomers.DataContext = db;