RadTreeView Value attribute

4 posts, 0 answers
  1. Daniel
    Daniel avatar
    1 posts
    Member since:
    Jul 2014

    Posted 06 Feb 2015 Link to this post

    I am populating a RadTreeView with a DataTable in c# with the display nodes showing CompanyNames, but I am not seeing any kind of hidden value attribute (CompanyID) in the source code when I view it from a browser.

    I assigned the DataFieldID's in the .aspx page but I do not see how I am supposed to retrieve the ID in the Code-Behind?

             treeManageUsers.DataTextField = "CompanyName";
                treeManageUsers.DataFieldID = "CompanyID";
                treeManageUsers.DataValueField = "CompanyID";
                treeManageUsers.DataSource = treeDT;

                <telerik:RadTreeView runat="server" ID="treeManageUsers" Skin="Telerik" 

  2. Ivan Danchev
    Ivan Danchev avatar
    788 posts

    Posted 11 Feb 2015 Link to this post


    Instead of getting the value from the DataFieldID property you can get it from the DataValueField property:

    protected void treeManageUsers_NodeClick(object sender, RadTreeNodeEventArgs e)
        RadTreeView tree = (RadTreeView)sender;
        var valueField = tree.DataValueField;

    Ivan Danchev

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

  3. DevCraft R3 2016 release webinar banner
  4. Boris
    Boris avatar
    275 posts
    Member since:
    Oct 2012

    Posted 04 Aug in reply to Ivan Danchev Link to this post

    Pardon my idle curiosity but isn't this rather redundant?  Why can't I access DataFieldId directly?

    (This gave me some difficulty as well.)

  5. Ivan Danchev
    Ivan Danchev avatar
    788 posts

    Posted 09 Aug Link to this post

    Hello Boris,

    You are correct, I should have said "Apart from" and not "Instead of". In Daniel's case the same field "CompanyID" is set to both the DataFieldID and the DataValueField properties so accessing either of those would return the same result. The clicked Node's ID can be accessed through the NodeClick event's arguments: e.Node.ID. 

    Ivan Danchev
    Telerik by Progress
    Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
Back to Top