RadtreeList UpdateCommand에서 DataKeyValue를 찾는 방법은 무엇입니까?
-
14-11-2019 - |
문제
업데이트를 수행 할 때 Datakey를 찾으십니까?나는 모든 것을 시도했다 ...
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
.
또한 insertCommand와 UpdateCommand에서 parentDataKeyValue도 찾아야하는 방법을 알고 싶습니다.
해결책
To get the DataKeyValue and the ParentDataKeyValue, change your last two lines to the following:
Dim editedItem As TreeListEditFormItem = CType(e.Item, TreeListEditFormItem)
Dim dataKeyValue As String = _
editedItem.ParentItem.GetDataKeyValue("EmployeeID").ToString()
Dim parentDataKeyValue As String = _
editedItem.ParentItem.GetParentDataKeyValue("ReportsTo").ToString()
Per Telerik's documentation, if you are using InPlace edit mode you should cast the TreeListEditableItem
to a TreeListDataItem
; if you are using EditForms you should cast the TreeListEditableItem
to a TreeListEditFormItem
.
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:
<telerik:RadTreeList ID="EmployeeTreeList" runat="server"
DataKeyNames="EmployeeID"
ParentDataKeyNames="ReportsTo">
<Columns>
<%-- Add column definitions here --%>
</Columns>
</telerik:RadTreeList>
제휴하지 않습니다 StackOverflow