Search code examples
devexpressxtragrid

XtraGrid checkEdit repository could not be checked/unchecked


I've devexpress XtraGrid populated with data using linq/LinqInstantFeedbackSource. The XtraGrid has a checkEdit repository bind with a column named Status from a table. The data elements in Status column are bits (0 or 1). However, for some unknown reason, the checkEdit could not be selected - i.e. I can't check/uncheck it. What could be the possible reason??


Solution

  • The reason is that the LinqInstantFeedbackSource is a read-only data source.

    UPDATE:
    As far as I can see you are using the anonymous type as result. Objects of the anonymous type have only read-only properties. It's impossible to modify them. That's why there are no editing in XtraGrid. If you need to obtain a collection of editable objects, don't use anonymous types.
    You can use this code, for example:

    var tcs=
        from tc in dc.TC 
        join dpt in dc.Departments on tc.DeptID equals dpt.DeptID 
        where tc.isReturned.Equals(0) 
        select new EditableObject { 
            MRN=tc.MRN, 
            DeptName=dpt.deptName + " - " + dpt.roomNo,
            IsReturned= tc.isReturned
        }; 
    

    where EditableObject is:

    public class EditableObject{
        public string MRN { get; set; }
        public string DeptName { get; set; }
        public bool IsReturned { get; set; }
    }