How to hide a column of SharePoint list in different mode (Add / Edit / Display Mode)?

Posted on Updated on

Most of the time we have requirement like that this field should be shown only in new mode or it should not be shown only in Edit mode not in new mode.

We can hide it in view by not to show in grid view but what to do if you do not want to see that field in Dispforms.aspx?

Here is the way how to do that.
Option: 1

SPSite site = new SPSite(”http://Server:3000/”);
SPWeb web = site.OpenWeb();
web.AllowUnsafeUpdates = true;
SPList list = web.Lists[”Sample”];
SPField objField = list.Fields[”Sample1″];
objField.ShowInNewForm = true;
objField.ShowInDisplayForm = false;
objField.ShowInEditForm = true;

Option: 2
List Definition
You can hide column appearing in New/Edit/View/ form by creating custom list defination for the list.

For creating custom list defination you can refer following MSDN link:

Now to hide a column from New/Edit/View/ form, you need to update content types of your list schema. Following is steps to do this (Assuming you have created custom list defination, following the steps mentioned in above URL):
1. Open schema.xml from your custom feature folder
2. Locate Content Types XML node, under that locates the Field which you want to hide from Edit form, set the ShowInEditForm value to FALSE.

Following example hides the Title column of custom list appearing in Edit form:

<FieldRef ID=”{fa564e0f-0c70-4ab9-b863-0177e6ddd247}” Name=”Title” Required=”TRUE” ShowInNewForm=”TRUE” ShowInEditForm=”FALSE” />


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s