As the title says, I need a way to programmatically edit an existing list view in sharepoint 2010. I found many examples of creating a new view:
SPList documents = web.Lists["Documents"];
StringCollection fields = new StringCollection();
fields.Add("Type");
fields.Add("Name");
fields.Add("File Size");
fields.Add("Modified");
fields.Add("Modified By");
fields.Add("Version");
var query = new XElement("Where",
new XElement("Eq",
new XElement("FieldRef", new XAttribute("Name", "Project")),
new XElement("Value", new XAttribute("Type", "Lookup"), "alpha")
)
).ToString(SaveOptions.DisableFormatting);
SPView view = documents.Views.Add(
"ProjectFilter",
fields,
query,
100,
false,
false,
Microsoft.SharePoint.SPViewCollection.SPViewType.Html,
false);
I also found some examples of editing an existing list by display fields:
SPList documents = web.Lists["Documents"];
SPview view = documents.Views["All Documents"];
view.ViewFields.Add("Price");
view.Update();
The only thing I didn't find is a way to modify an existing view filtering it with a CAML request, in the same way as above when I created it
Is there any way to do this?
source
share