Skip to content
Amal Hashim
All posts
Snippet

SharePoint List - Display Field Only On View Mode

Create a list field that appears on the display form but is hidden from the new and edit forms.

1 min read#C##SharePoint

Sometimes a field should be visible when an item is viewed, but never editable. Set ShowInNewForm and ShowInEditForm to FALSE when you add the field.

csharp
string newField = "<Field Type=\"Text\" MaxLength=\"50\" DisplayName=\"NewField\" Name=\"NewField\" ShowInNewForm=\"FALSE\" ShowInEditForm=\"FALSE\" />";
list.Fields.AddFieldAsXml(newField, true, SPAddFieldOptions.Default);

The field now shows on the view form only. Your code can still fill it in from an event receiver or workflow.