Customize defaultview extension method

This is an extension method that I have used numerous times in feature receivers that creates instances of lists and I needed to customize the default view (AllItems.aspx) on that list.
It looks like this:

public static void CustomizeDefaultView(this SPList instance, params Guid[] viewFieldsIds)
    SPView view = instance.DefaultView;

    foreach (Guid viewFieldsId in viewFieldsIds)



And you can call it like this:

SPList instance = AccessList();

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





, ,

  1. HowTo: Add SPList based on a custom template « Johan Leino

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 )

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: