Wednesday, October 22, 2008

How to programatically delete a SharePoint 2007 field belonging to a list or document library?

Here's the code for deleting a field named "phone" in list "myList" on a site with URL http://mysite/:

try {

using (SPSite sitecollection = new SPSite("http://mysite/")) {

using (SPWeb web = sitecollection.OpenWeb()) {

web.AllowUnsafeUpdates = true;

// Delete Sharepoint SPField



Console.WriteLine("Done deleting column");



} catch (Exception ex) {



No comments:

Post a Comment