문제

사용자 정의 NewForm에서 BooleanField 값을 설정하려고합니다. codebehind에서 그것을하려고 시도하면 시각적으로 변경되지 않지만 항목이 저장 될 때이 필드가 비어 있습니다 (true 또는 false도 없음).

aspx :

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

aspx.cs (onload 메소드 호출) :

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

도 .aspx에서 설정하려고했습니다 (그리고 "파서 오류 메시지") :

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

그러나 다른 유형의 필드를 변경하려고 시도하면 모든 것이 괜찮을 것입니다.

어디에서 틀린가, 그리고 어떻게 codebehind (또는 적어도 aspx에서)에서 어떻게 할 수 있습니까?

미리 감사드립니다!=)

도움이 되었습니까?

해결책

Alex,

You should set the control as follow:

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

Where 1 is for true, and 0 is for false

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 sharepoint.stackexchange
scroll top