当前位置: 首页>>代码示例>>C#>>正文


C# SPField.Update方法代码示例

本文整理汇总了C#中SPField.Update方法的典型用法代码示例。如果您正苦于以下问题:C# SPField.Update方法的具体用法?C# SPField.Update怎么用?C# SPField.Update使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SPField的用法示例。


在下文中一共展示了SPField.Update方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: RemoveField

            public static bool RemoveField(SPField spField)
            {
                bool res = false;
                try
                {
                    if (spField == null)
                    {
                        return res;
                    }
                    // check if it's a ReadOnly field.
                    // if so, reset it
                    if (spField.ReadOnlyField)
                    {
                        spField.ReadOnlyField = false;
                        spField.Update();
                    }

                    // check if it's a Hidden field.
                    // if so, reset it
                    if (spField.Hidden)
                    {
                        spField.Hidden = false;
                        spField.Update();
                    }

                    // check if the AllowDeletion property is set to false.
                    // if so, reset it to true
                    if (spField.AllowDeletion == null || !spField.AllowDeletion.Value)
                    {
                        spField.AllowDeletion = true;
                        spField.Update();
                    }

                    // finally, remove the field
                    spField.Delete();
                    spField.ParentList.Update();

                    res = true;
                }
                catch (Exception ex)
                {
                    UlsLogging.LogError("ListField. RemoveField(SPField spField). Message: {0}, StackTrace: {1}", ex.Message, ex.StackTrace);
                }

                return res;
            }
开发者ID:dimanngo,项目名称:SharePoint13Helper,代码行数:46,代码来源:ListManager.cs

示例2: CreateIndexedField

 /// <summary>
 /// Indicates whether field will indexed.
 /// </summary>
 /// <param name="field"></param>
 public static void CreateIndexedField(SPField field)
 {
     if (!field.Indexed)
     {
         field.Indexed = true;
         field.Update();
     }
 }
开发者ID:setsunafjava,项目名称:vpsp,代码行数:12,代码来源:ListHelper.cs

示例3: ConfigureFieldTitleResource

        // ===========================================================================================================
        /// <summary>
        /// Configures the TitleResource of the given <b>SPField</b> based on the specified <b>Field</b> config
        /// </summary>
        /// <param name="field">The <b>SPField</b> that needs to be configured</param>
        /// <param name="configField">The <b>Field</b> config</param>
        // ===========================================================================================================
        private void ConfigureFieldTitleResource(SPField field, Field configField)
        {
            logger.Info("Configuring title resources for field '{0}'", field.InternalName);

            foreach(TitleResource titleResource in configField.TitleResources)
            {
                field.TitleResource.SetValueForUICulture(new CultureInfo(titleResource.LCID), titleResource.Value);
            }
            field.Update();
        }
开发者ID:coupalm,项目名称:PnP,代码行数:17,代码来源:SiteFieldsProvider.cs

示例4: UpdateField

 public virtual void UpdateField(SPField field, bool pushChangesToList)
 {
     field.Update(pushChangesToList);
 }
开发者ID:powareverb,项目名称:spgenesis,代码行数:4,代码来源:SPGENFieldStorage.cs

示例5: FixupField

        static void FixupField(SPField spField)
        {
            // This method takes an InternalName of a field in a spList and process a few things we want all fields to have by default
            // for example setting them to show into the default view
            spField.ShowInDisplayForm = true;
            spField.ShowInEditForm = true;
            spField.ShowInListSettings = true;
            spField.ShowInNewForm = true;
            spField.ShowInVersionHistory = true;
            spField.ShowInViewForms = true;

            // Add field to default view
            SPView defaultView = spField.ParentList.DefaultView;
            defaultView.ViewFields.Add(spField);
            defaultView.Update();

            spField.Update();
        }
开发者ID:sreekanth642,项目名称:sp2010_lab,代码行数:18,代码来源:Program.cs

示例6: SetDefaultTaxonomyValue

        /// <summary>
        /// Set default value for a taxonomy site column
        /// </summary>
        /// <param name="web">The web.</param>
        /// <param name="field">The field.</param>
        /// <param name="termGroupName">The term group name.</param>
        /// <param name="termSetName">the term set name.</param>
        /// <param name="termLabel">The term label.</param>
        public void SetDefaultTaxonomyValue(SPWeb web, SPField field, string termGroupName, string termSetName, string termLabel)
        {
            var term = this._taxonomyService.GetTaxonomyValueForLabel(web.Site, termGroupName, termSetName, termLabel);

            var taxonomySession = new TaxonomySession(web.Site);
            TermStore termStore = taxonomySession.DefaultSiteCollectionTermStore;

            var termGroup = termStore.Groups[termGroupName];
            var termSet = termGroup.TermSets[termSetName];

            if (term != null)
            {
                var statusTaxonomyFieldDefaultValue = new TaxonomyFieldValue(field);
                string path = TaxonomyItem.NormalizeName(term.Label) + TaxonomyField.TaxonomyGuidLabelDelimiter
                              + term.Id.ToString();
                statusTaxonomyFieldDefaultValue.PopulateFromLabelGuidPair(path);

                int[] ids = TaxonomyField.GetWssIdsOfTerm(web.Site, termStore.Id, termSet.Id, term.Id, true, 1);

                if (ids.Length == 0)
                {
                    statusTaxonomyFieldDefaultValue.WssId = -1;
                }

                statusTaxonomyFieldDefaultValue.TermGuid = statusTaxonomyFieldDefaultValue.TermGuid.ToUpperInvariant();
                field.DefaultValue = statusTaxonomyFieldDefaultValue.ValidatedString;
                field.Update();
            }
        }
开发者ID:GAlexandreBastien,项目名称:Dynamite-2010,代码行数:37,代码来源:TaxonomyHelper.cs


注:本文中的SPField.Update方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。