I have a DevExpress xtraGrid which I want to bind. When I try to bind, the compiler gives an error that the gridView datasource is readonly. I tried the below approach, my code is
NorthwindDataContext db = new NorthwindDataContext();
var r = from p in db.Orders
select p;
var r2 = from p in db.Order_Details
select p;
gridView1.DataSource = r;
gridView2.DataSource = r2;
I get the following error: Property or indexer 'DevExpress.XtraGrid.Views.Base.BaseView.DataSource' cannot be assigned to -- it is read only
I checked my column property of on the gridView and It is not read only. Why I am getting this error? Actually my grid is empty, I am going to bind it to a database.
You need to set the DataSource
of the GridControl
that controls your GridView
, not of the GridView
itself.
From DevExpress's site: How to: Bind a Control to a Database at Runtime