Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why grid become readonly? How to avoide readonly grid problem?

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.

like image 312
shamim Avatar asked Sep 12 '25 20:09

shamim


1 Answers

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

like image 108
dsolimano Avatar answered Sep 15 '25 11:09

dsolimano