This is a migrated thread and some comments may be shown as answers.

RadTreeView Value attribute

3 Answers 353 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Daniel
Top achievements
Rank 1
Daniel asked on 06 Feb 2015, 03:49 PM
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;
            treeManageUsers.DataBind();


            <telerik:RadTreeView runat="server" ID="treeManageUsers" Skin="Telerik" 
                OnNodeClick="treeManageUsers_NodeClick" 
                DataTextField="CompanyName" 
                DataFieldID="CompanyID">
            </telerik:RadTreeView>


3 Answers, 1 is accepted

Sort by
0
Ivan Danchev
Telerik team
answered on 11 Feb 2015, 09:05 AM
Hello,

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;
}


Regards,
Ivan Danchev
Telerik
 

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.

 
0
Boris
Top achievements
Rank 1
answered on 04 Aug 2016, 04:22 PM

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

(This gave me some difficulty as well.)

0
Ivan Danchev
Telerik team
answered on 09 Aug 2016, 10:52 AM
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. 

Regards,
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.
Tags
TreeView
Asked by
Daniel
Top achievements
Rank 1
Answers by
Ivan Danchev
Telerik team
Boris
Top achievements
Rank 1
Share this question
or