D
Dave Cotton
Howdy,
I'm using a DataRowView that I create via a
BindingContext from a DataGrid. The problem is that
sometimes I get an exception that says Cannot Set 'column
name'. I'm wondering if anyone is familiar with this
message and under what conditions it might occur. And of
course, a way around the problem.
I'm using C# 7.0.9466, I've updated the framework to 1.1.
Also, this is not a web app. Currently the code looks
like this:
BindingManagerBase BMB = BindingContext
[dataGrid1.DataSource, dataGrid1.DataMember];
PropertyDescriptorCollection pc = BMB.GetItemProperties();
BMB.Position = (int)dataGrid1.SelList[0];
DataRowView drv = (DataRowView)BMB.Current;
I've also tried:
DataRowView drv = (DataRowView)BindingContext
[dataGrid1.DataSource, dataGrid1.DataMember].Current;
The SelList property is something I added that keeps
track of which rows are currently selected. It's
primarily used to do a multi-row update. However, since
the multi-update works and the single update doesn't.
I've been trying to make the single update more like the
multi-update. Thus, the reason for the change from the
simple BindingContext that I noted I tried.
The actual exception occurs on this statement:
drv["Name"] = str;
When I try to set the value of the field. I've looked at
the properties just before the read and ReadOnly is
false. I can read from the field. I just cannot, for some
reason, set the field value.
I've also checked drv.DataView.AllowEdit this value is
also true. Interestingly,
drv.Row.ItemArray[3] = "Value";
does not give an exception.
Thanks,
Dave
I'm using a DataRowView that I create via a
BindingContext from a DataGrid. The problem is that
sometimes I get an exception that says Cannot Set 'column
name'. I'm wondering if anyone is familiar with this
message and under what conditions it might occur. And of
course, a way around the problem.
I'm using C# 7.0.9466, I've updated the framework to 1.1.
Also, this is not a web app. Currently the code looks
like this:
BindingManagerBase BMB = BindingContext
[dataGrid1.DataSource, dataGrid1.DataMember];
PropertyDescriptorCollection pc = BMB.GetItemProperties();
BMB.Position = (int)dataGrid1.SelList[0];
DataRowView drv = (DataRowView)BMB.Current;
I've also tried:
DataRowView drv = (DataRowView)BindingContext
[dataGrid1.DataSource, dataGrid1.DataMember].Current;
The SelList property is something I added that keeps
track of which rows are currently selected. It's
primarily used to do a multi-row update. However, since
the multi-update works and the single update doesn't.
I've been trying to make the single update more like the
multi-update. Thus, the reason for the change from the
simple BindingContext that I noted I tried.
The actual exception occurs on this statement:
drv["Name"] = str;
When I try to set the value of the field. I've looked at
the properties just before the read and ReadOnly is
false. I can read from the field. I just cannot, for some
reason, set the field value.
I've also checked drv.DataView.AllowEdit this value is
also true. Interestingly,
drv.Row.ItemArray[3] = "Value";
does not give an exception.
Thanks,
Dave