Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

SPField.Update method

Updates the database with changes that are made to the field.

Namespace:  Microsoft.SharePoint
Assembly:  Microsoft.SharePoint (in Microsoft.SharePoint.dll)
[ClientCallableExceptionConstraintAttribute(FixedId = "2", ErrorCode = , Condition = "Tying to un-index a field which does not allow duplicate values.", 
	ErrorType = typeof(SPException))]
[ClientCallableAttribute]
[ClientCallableExceptionConstraintAttribute(FixedId = "6", ErrorCode = , Condition = "Trying to change the type of a field which is also changing to be indexed or which is already indexed.", 
	ErrorType = typeof(SPException))]
[ClientCallableExceptionConstraintAttribute(FixedId = "3", ErrorCode = , Condition = "Trying to change the type of a field which does not allow duplicate values.", 
	ErrorType = typeof(SPException))]
public virtual void Update()
ExceptionCondition
SPException

An error was encountered during the operation.

The following code example updates the display name, default value, and description for the specified field.

SPSite oSiteCollection = SPContext.Current.Site;
SPList oList = 
    oSiteCollection.AllWebs["Site_Name"].Lists["List_Name"];
SPField oField = oList.Fields["Field_Name"];

oField.DefaultValue = "Default_Value";
oField.Description = "Description";
oField.Title = "New_Field_Title";

oField.Update();
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.