RadTreeList with RadContextMenu (how do I get the Primary Key and ParentID of the selected node?)

575 Views Asked by At

I am using a RadTreeList control to display a bunch of items. I added a RadContextMenu to the page and set the OnItemClick event so I can use it in the code behind to set the URL of my RadWindow based on Insert and Edit. Then I open a radwindow using that url.

It looks exactly like the one in this demo

    protected void rcMenu_ItemClick(object sender, RadMenuEventArgs e)
    {
        switch (e.Item.Value)
        {
            case "Insert":
                url = "~/Admin/ManageItemsDialog.aspx?ID="
                break;
            case "Edit":
                url = "~/Admin/ManageItemsDialog.aspx?ID="
                break;
        }
}

In here I am trying to retrieve the ID and the ParentID of the selected item from the tree list. The ultimate goal is to open a RadWindow passing the ID and ParentID through the URL.

1

There are 1 best solutions below

1
On BEST ANSWER

Use the SelectedItems property of the TreeList control. Open the RadWindow as shown here: http://www.telerik.com/help/aspnet-ajax/window-troubleshooting-opening-from-server.html. Its GetDataKeyValue method will give you the needed values

Also, consider doing this on the client only: Telerik ASP.NET AJAX: How to get value of a data bound column, client-side. The get_selectedItems() will give you the needed items http://www.telerik.com/help/aspnet-ajax/treelist-client-side-basics.html