SPList currentList = currentWeb.Lists["DocLib"];
SPField newField = currentList.Fields.CreateNewField(SPFieldType.Text.ToString(), "New Field2");
currentList.Fields.AddFieldAsXml(newField.SchemaXml, true, SPAddFieldOptions.AddToAllContentTypes);
currentList.Update();
I found this code and an excellent explanation on this blog http://blogs.microsoft.co.il/blogs/davidbi/archive/2009/01/22/sharepoint-add-a-spfield-to-all-the-content-types-in-a-splist.aspx
No comments:
Post a Comment