How to add LinkTitle column to a Document Library

I have previously used the field LinkTitle to show the ECB menu in the AllItems.aspx default view on custom SharePoint list instances, like:


I used the same code as I had used before which looked like this:

 

SPList instance = AccessList();

instance.CustomizeDefaultView(new Guid[]
{
 SPBuiltInFieldId.LinkTitle,
 new Guid("69a5f580-2e33-4bdc-87e2-0888e20e3046"),
 new Guid("f17f0fc3-f240-4a54-9736-5fa9a0fe0a26")

});

 Note: This code uses an extension method that I have blogged about before.

When the code ran, I got an exception claiming that the field (LinkTitle) doesn´t exist.

After some digging I found that in document libraries you have to use LinkFilename instead, like this:

 

 

SPList instance = AccessList();

instance.CustomizeDefaultView(new Guid[]
{
 SPBuiltInFieldId.LinkFilename,
 new Guid("69a5f580-2e33-4bdc-87e2-0888e20e3046"),
 new Guid("f17f0fc3-f240-4a54-9736-5fa9a0fe0a26")

});

, ,

  1. Leave a comment

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s

%d bloggers like this: