Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

Is there a way to mass update a bunch of views at the same time (add/remove columns to all views in a particular list)? We have a significant number of views, so it would be nice if we could update a bunch of them at the same time.

share|improve this question

1 Answer 1

up vote 0 down vote accepted

AFAIK SharePoint UI does not allow this but you could write a simple app to change your views. Check sample from Programmatically create a view (custom view) of a list and change the view below:

SPSite oSite = new SPSite([Site URL]);// [Site URL] change it to your sharepoint site URL
SPWeb oWeb = oSite.OpenWeb();
SPList oList = oWeb.Lists["shared documents"];  
SPViewCollection oViewCollection = oList.Views;

            string strViewName = "MyCustomView";

            System.Collections.Specialized.StringCollection viewFields =
            new System.Collections.Specialized.StringCollection();

            viewFields.Add("Name");
            viewFields.Add("Type");

            string query = "<Where><Eq><FieldRef Name=\"Name\"/>" +
                "<Value Type=\"Text\">mysample</Value></Eq></Where>";// here you can filter your items using the selected
                                                                         item in the dropdownlist
            oViewCollection.Add(strViewName, viewFields, query, 100, true, false);

 oWeb.Update();
share|improve this answer
    
Thanks for the post. I had a feeling this was the only way. –  user1627 Nov 1 '10 at 18:07

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.