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
web.Lists["myList"].Fields.Delete("phone");
web.Update();
Console.WriteLine("Done deleting column");
}
}
} catch (Exception ex) {
Console.WriteLine(ex.ToString());
}
No comments:
Post a Comment