質問

カスタムNewformにBooleanfieldの値を設定しようとしています。 CodeBehindからそれをやろうとすると、視覚的には変更されませんが、アイテムが保存されるとこのフィールドが空になります(真実も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"/>
.

しかし、他の種類のフィールドを変更しようとした場合(たとえば、NumberField)、すべて問題になります。

どこに間違っていますか、そしてコードベーインド(または少なくとも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