In a custom form, I want to display my own Guid field.
I created the field in the usual way using the function:
<Field ID="88813c02-799b-4fc8-8ed8-72fe668e257c" Type="Guid" Name="myGuid" StaticName="myGuid" DisplayName="My Guid" />
This is the field that I want to first set through the code and display in the form. In the form, I have the following control (for the link, I also include a header):
<SharePoint:GuidField runat="server" ID="myGuidField" FieldName="myGuid" /> <SharePoint:TextField runat="server" ID="myTitle" FieldName="Title" />
The Guid field is not displayed in the usual New / Edit form - it is simply empty. In the code behind the user form, I can do the following:
myTitle.Value = "Some Title Value"; string testValue = myTitle.Value; //-->"Some Title Value"
but when you try to set the value of the Guid field, this somehow cannot be done:
string anotherValue = myGuidField.Value; //--> null Guid myGuid = new Guid("7f824c3f-4049-4034-a231-85291fce2680"); myGuidField.Value = myGuid; string anotherValue = myGuidField.Value; //--> still null //but myGuidField is seen as a "Microsoft.Sharepoint.WebControls.GuidField"
So, anyway, I just can't set the Guid value programmatically, and I can't only display Guid.
Two questions:
- How to display a GuidField (containing its GUID) in a form?
- How to set the value of GuidField
source share