On a custom form of mine I want to display a custom Guid field.
I created the field the usual way via a feature:
<Field ID="88813c02-799b-4fc8-8ed8-72fe668e257c" Type="Guid"
Name="myGuid"
StaticName="myGuid"
DisplayName="My Guid" />
This field I want first set via code and display on a form. On the form I have the following control (for reference I also include a title field):
<SharePoint:GuidField runat="server" ID="myGuidField" FieldName="myGuid" />
<SharePoint:TextField runat="server" ID="myTitle" FieldName="Title" />
The Guid field doesn't display on a regular New/Edit form - it's simply empty. In the code behind of the custom form I can do the following:
myTitle.Value = "Some Title Value";
string testValue = myTitle.Value; //-->"Some Title Value"
but when trying to set the value of the Guid field - it 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 somehow I'm just not able to set the Guid value programmatically and I'm neither able to only display the Guid.
Two questions:
- How to display a GuidField (the GUID it contains) on a form?
- How to set the value of a GuidField