Question

I have a GridView bound to an ObjectDataSource that returns some instances of MyDto. All is working, except that in a column I want to show a value calculated in MyDto (by a readonly property) and this cause some problem during editing. The editing mode is inline.

I set that column readonly property = True and Visible = False in EditFormSettings, but when I insert a new row and I press Update the ObjectDataSource throw the exception "The 'CalculatedValue' property on the type specified by the DataObjectTypeName property in ObjectDataSource 'MyDataSource' is readonly and its value cannot be set."

I don't understand why the GridView is trying to update a readonly value. Thank you.

Was it helpful?

Solution

The problem arises because the GridView, automatically, try to update EVERY bound column, readonly or not (readonly is respect from the user perspective).

I've edited the EditItemTemplate for the calculated column inserting an empty template. In this way I see nothing in editing mode and the GridView does not try to update the readonly property, and I see the (automatically created) bound template (with the calculated value) in display mode.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top