Portal Engine
Version 3.x > Portal Engine > CMSContext.CurrentDocument.DocumentContent.EditableWebParts.Add Method View modes: 
User avatar
Member
Member
Paul - 2/3/2009 5:13:09 AM
   
CMSContext.CurrentDocument.DocumentContent.EditableWebParts.Add Method
This is my sample code:

Dim webpart_id As String = CType(PartInstance.GetValue("WebPartControlID"), String).ToString
If Not CMSContext.CurrentDocument.DocumentContent.EditableWebParts.ContainsKey(webpart_id) Then
CMSContext.CurrentDocument.DocumentContent.EditableWebParts.Add("new_webpart_id_key", "new_webpart_value")
End If

It does not seem to add (as in insert) a new key/value item to the DocumentContent database column. Instead it replaces the only existing key/value pair.

What is the best way to insert a new key/value pair to the DocumentContent database field?


User avatar
Kentico Support
Kentico Support
kentico_jurajo - 2/3/2009 8:16:31 AM
   
RE:CMSContext.CurrentDocument.DocumentContent.EditableWebParts.Add Method
Hi,

You approach is not correct. DocumentContent property is read only. You need to store the data using the TreeNode and add them to the XML of this node and save it.

Best Regards,
Juraj Ondrus