I have a cell that I need to set the date:
e.Row.Cells["scheduled_date"].Value = schedulingDate;
When the code is executed, the following error is created:
Column 'scheduled_date' is read only.
I have tried the CellActivation, etc., but have not been able to figure out how to set the cell to allow me to set the date. Thanks!
CODE:
bool ro = e.Row.Cells.IsReadOnly; //--> returns TRUE; Ok
e.Row.Cells["scheduled_date"].IgnoreRowColActivation = true;
// the e.Row.Cells["scheduled_date"].Activation value is already set to "'AllowEdit"
e.Row.Cells["scheduled_date"].Activation = Activation.AllowEdit;
ro = e.Row.Cells.IsReadOnly; // --> returns TRUE; why??
e.Row.Cells["scheduled_date"].Value = schedulingDate; // --> throws exception
Hi,
I doubt this has anything to do with the grid. If a cell is made ReadOnly in the grid, this will prevent the user from updating the cell, but it does not prevent you from updating it in code.
My guess is that your data source column is readonly and it is the data source that is raising this error message.
Mike,
thanks - sorry for teh delay in responding... so the cell read only attribute is effected by the grid and the datasource dataset?
to make this checng I need to look at the dataset attribute and flip that value to make the update? I will give that a try
(I was thinking if I modified the cell attirbute I could make the change)
It's a little more complex than that.
If the data source does not allow editing, then the grid will never allow you to edit the cell. It cannot - since it cannot write the changes to the data source.
If the data source does allow editing, you can then use the properties on the grid to disable or restrict editing further.
Those properties only affect the user, though. There is no property setting the grid that will prevent you from changing the value of a cell in code.
So I could be wrong, but my best guess is that you are unable to update the cell because the data source will not allow it. In which case, the only solution is to change the data source to allow it. You can, of course, still restrict the user from changing the values in the grid.
yep - the datasource was set - that is what I did not grasp - with the data source set to read only, changing the attribute at the grid was ineffective - thanks!