Hi All,
below example will explain how to associate a content type with list in sharepoint.
SPList oList = oWeb.Lists.TryGetList("ListName");
SPContentType cType = oWeb.ContentTypes["ContentTypeName"];
if (cType != null)
{
//enabling the content type for the list
oList.ContentTypesEnabled = true;
//associating content type with list
oList.ContentTypes.Add(cType);
oList.Update();
}
Related Post
Library
- Import Data From XML
- Import Data from Excel to Dataverse using PowerApps
- Column formatting in modern list view
- Get List Field Type using ECMA Script in SP Hosted Apps
- Related Items Column in SharePoint 2013
- Set List/Library Default Content Type Programatically
- Difference between List and Library in SharePoint
0 comments:
Post a Comment