How on earth do I find the DataKey when I'm doing an update? I've tried everything...
Private Sub rtlAccounts_UpdateCommand(ByVal sender As Object, ByVal e As Telerik.Web.UI.TreeListCommandEventArgs) Handles rtlAccounts.UpdateCommand
Dim txtAccountDescription As RadTextBox = TryCast(e.Item.FindControl("txtAccountDescription"), RadTextBox)
Dim txtAdminName As RadTextBox = TryCast(e.Item.FindControl("txtAdminName"), RadTextBox)
Dim txtAdminEmail As RadTextBox = TryCast(e.Item.FindControl("txtAdminEmail"), RadTextBox)
Dim rcbStatus As RadComboBox = TryCast(e.Item.FindControl("rcbStatus"), RadComboBox)
Dim rntDocRetention As RadNumericTextBox = TryCast(e.Item.FindControl("rntDocRetention"), RadNumericTextBox)
Dim item As TreeListEditableItem = TryCast(e.Item, TreeListEditableItem)
Dim MyDataKeyID As String = 'Now what???
End Sub
Also would like to know how to find the ParentDataKeyValue from an InsertCommand and the UpdateCommand as well.
To get the DataKeyValue and the ParentDataKeyValue, change your last two lines to the following:
Per Telerik's documentation, if you are using InPlace edit mode you should cast the
TreeListEditableItem
to aTreeListDataItem
; if you are using EditForms you should cast theTreeListEditableItem
to aTreeListEditFormItem
.In order for GetDataKeyValue and GetParentDataKeyValue to return the values you want, you must set them in the respective DataKeyNames and ParentDataKeyNames values when defining a RadTreeList: