We have a gridview.ItemSource = datafilter.FilterdSource and the datafilter.Source = datatable.DefaultView. When we (manually) generate the columns they are type of GridViewColumnBase and the columns to be updated are of DataType System.String. The gridview is set to readonly and we set some values in the background depending on user actions. Generally the action is based on a context menu click and we are accessing the record as (gridview.Items[i] as DataRowView). We then set the value of the cell by the column name and it works great but sometimes it will give us an exception saying the column 'x' is readonly... can't figure our why.
Routine to update is similar to the following:
Error:
Message: Column 'ColumnUniqueName' is read only.
Routine to update is similar to the following:
string
c =
"ColumnUniqueName"
, v =
"ValueToSet"
;
DataRowView r = (gridview.Items[i]
as
DataRowView);
r[c] = v;
//her we get the error
Error:
Message: Column 'ColumnUniqueName' is read only.
Source: System.Data
Trace: at System.Data.DataRow.set_Item(DataColumn column, Object value)
at System.Data.DataRowView.SetColumnValue(DataColumn column, Object value)
at System.Data.DataRowView.set_Item(String property, Object value)