SharePoint : Programmatically setting read-only columns erases the value in the other columns

PROBLEM : The share point list has 2 custom columns and the list has some values in the custom columns. You programmatically set the read only property of the first column to true. After that, when you edit the value of the second column through the data sheet view, the value of the first column was erased.


When set the readonly property to true, apply the following code

 localhost.Lists listService = new localhost.Lists();
listService.Credentials= System.Net.CredentialCache.DefaultCredentials;
XmlDocument xmlDoc = new System.Xml.XmlDocument();
XmlNode ndUpdateFields = xmlDoc.CreateNode(XmlNodeType.Element, "Fields", "");
ndUpdateFields.InnerXml = "<Method ID='1'>" +
"<Field ReadOnly='True' ShowInEditForm = 'FALSE' Type='Number' Name='_x0043_ol1' DisplayName='Col1'/>" +
XmlNode ndReturn = listService.UpdateList("Events", null, null, ndUpdateFields, null, null);
catch (Exception ex)
MessageBox.Show("Message:\n" + ex.Message + "\nStackTrace:\n" + ex.StackTrace);

Note :
Use the same case sensitivity in the xml fields. For e.g. ReadOnly=’True’, and it is not ReadOnly=’TRUE’