0

Wondering if you could help me please. Currently have a page layout with a SharePointWebControl inserted on the page:

<SharePointWebControls:FieldValue FieldName="Boolean1" runat="server" />

The field itself is a SharePoint "Yes/No" field and currently displays "yes" or "no", however I want to get the value as "true", "false", "1" or "0"

Just wondering if anyone knows of a way of doing this please.

  • Have you tried SharePointWebControls:BooleanField instead of SharePointWebControls:FieldValue – Arsalan Adam Khatri Oct 10 '17 at 10:28
1

You should set the control as follow:

MyCustomField.ItemFieldValue = "1";
MyCustomField.Field.DefaultValue = "1";

Where 1 is for true, and 0 is for false

ASPX

<SharePoint:BooleanField runat="server" FieldName="boolField" ControlMode="New" ID="MyCustomField"/>

ASPX.CS

if (!SPContext.Current.Web.CurrentUser.IsSiteAdmin) // For example
{
 MyCustomField.Value = true; // Visually no changes
 MyCustomField.UpdateFieldValueInItem(); // Still nothing
}

For Reference: https://www.schaeflein.net/enhanced-booleanfield-control-for-sharepoint-publishing/

Helpful link: For Good Answer similar question

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.