Wednesday, August 24, 2011

Specified method is not supported - ASPxGridView Exception


When you use a complex LINQ query, the result that is returned from the Linq-To-Sql is a
projection that can't be edited. All its properties are set as read-only.
The DataController determines that the datasource has fields with get accessors only, and
"tells" the ASPxGridView to render fields in readonly mode.

A possible solution is to remove the ReadOnly attribute in the ASPxGridView.CellEditorInitialize
event handler:
[C#]
e.Editor.ReadOnly = false;
A custom updating and inserting can be implemented by handling the ASPxGridView.RowUpdating
and ASPxGridView.RowInserting events.
[C#]
var obj = /* find an object by e.Keys[0] */;
obj.Prop = e.NewValues["Prop"];
...
obj.Save;

e.Cancel = true;
grid.CancelEdit();

When you do insert or Update Operations in the DevExpress ASPxGridView then this kind of
exception occurred after completing these operations. To prevent this just add the following two lines
of code to avoid the problem in the  RowInsert or RowUpdating events.
e.Cancel = true;
grid.CancelEdit();

1 comment :

  1. Are you looking to make cash from your traffic by popup advertisments?
    If so, did you take a look at Ero Advertising?

    ReplyDelete