本文整理汇总了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;
}
示例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();
}
}
示例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();
}
示例4: UpdateField
public virtual void UpdateField(SPField field, bool pushChangesToList)
{
field.Update(pushChangesToList);
}
示例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();
}
示例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();
}
}