如何从RadTreeList UpdateCommand中找到DataKeyValue?

发布于 2024-11-08 02:21:59 字数 920 浏览 1 评论 0原文

当我进行更新时,我到底如何找到 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 。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

蓝礼 2024-11-15 02:21:59

要获取 DataKeyValue 和 ParentDataKeyValue,请将最后两行更改为以下内容:

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 的文档,如果您使用 InPlace 编辑模式,您应该将 TreeListEditableItem 转换为TreeListDataItem;如果您使用 EditForms,则应将 TreeListEditableItem 转换为 TreeListEditFormItem

为了让 GetDataKeyValue 和 GetParentDataKeyValue 返回您想要的值,您必须在定义 RadTreeList 时在各自的 DataKeyNames 和 ParentDataKeyNames 值中设置它们:

<telerik:RadTreeList ID="EmployeeTreeList" runat="server" 
    DataKeyNames="EmployeeID" 
    ParentDataKeyNames="ReportsTo">
    <Columns>
        <%-- Add column definitions here --%>
    </Columns>
</telerik:RadTreeList>

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>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文