private static void MarkReadOnlyFields(ViewTemplate template, string fieldsToShowReadOnly) { string[] readOnlyFields = SplitUpFieldNames(fieldsToShowReadOnly); for (int i = 0; i < template.Count; i++) { Field field = template[i]; foreach (string s in readOnlyFields) { if (s == field.FieldName) { Field readOnlyVersion = new Field(field); readOnlyVersion.Visibility = CommonEnumerations.VisibilitySetting.ReadOnly; template.Remove(field); template.Insert(i, readOnlyVersion); } } } }