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

Tree View DataBind Issue

5 Answers 86 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Balamurali Venkatesan
Top achievements
Rank 1
Balamurali Venkatesan asked on 22 Apr 2009, 06:25 PM
Hi ,
     I am trying to bind the data to  telerick tree view dataSoure .But the data not getting into binded to the tree  view.Telerick tree view is not rendering to the page with data in ItemCommand event.


Please find the code below which I am using to bind the data tree view in ItemCommand event

 

protected void radGridHierarchies_ItemCommand(object source, GridCommandEventArgs e)

 

{

 

if (e.CommandName == "RowClick" && radGridHierarchies.SelectedItems.Count == 1)

 

{

 

int datascopeId = Convert.ToInt32(radGridHierarchies.SelectedValues["DatasourceId"]);

 

 

int dimensionId = Convert.ToInt32(radGridHierarchies.SelectedValues["DimensionId"]);

 

 

string hierName = radGridHierarchies.SelectedValues["HierarchyName"].ToString();

 

datascopeId = 11;

 

List<CharHierLevel> lstHierLevel = _presenter.GetCharHierLevelDetails(datascopeId, dimensionId, hierName);

 

radTreeCharHierLevel.DataTextField =

"HierarchyLevelName";

 

radTreeCharHierLevel.DataValueField =

"HierarchyLevelName";

 

radTreeCharHierLevel.DataFieldID =

"HierarchyLevelName";

 

radTreeCharHierLevel.DataFieldParentID =

"HierarchyLevelParent";

 

radTreeCharHierLevel.DataSource = lstHierLevel;

radTreeCharHierLevel.DataBind();

}

 

}

Note:The issue I could not find in design time .if any one got this king of issue the Immediate help will be highly appreciated

5 Answers, 1 is accepted

Sort by
0
Yana
Telerik team
answered on 23 Apr 2009, 01:37 PM
Hi Balamurali,

Please review this help article which explains how to bind RadTreeView to hierarchical data, note that  DataFieldParentID should be null for root nodes or the id of the parent node, also DataFieldID should be a unique identifier of all nodes.

Best wishes,
Yana
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
awni
Top achievements
Rank 1
answered on 18 Oct 2011, 11:24 PM
Hi,
I'm trying to bind data to treeview but I'm not sure if this considered hierarchical. What I have is a groups of Drivers and I want to have the group name as the parent node and the driver name as the child node. I have 2 tables:
Groups 
   groupId
  groupName
Drivers 
   driverId
   driverName

the tree should look like this:

Sales
---- Dave
---- Bob
---- John
Admin
---- Ron
---- Mike

How would achieve this using RAD Controls for ASP.NET AJAX? 

thanks,
awni






0
Plamen
Telerik team
answered on 19 Oct 2011, 08:41 AM
Hi Awni,

You can refer to the Binding to Hierarchical Data help article, where a similar functionality is explained.

Hope this will help you.

Regards,
Plamen Zdravkov
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
0
awni
Top achievements
Rank 1
answered on 19 Oct 2011, 01:44 PM
Thank you, that worked. I had to change the Ids of the parent(group) table so they don't coincide with the child(driver) ids. 

thanks again :)
awni
0
awni
Top achievements
Rank 1
answered on 22 Oct 2011, 10:41 PM
Hi, I have another question please: 
I tried the get_text() method used in this example and it worked OK:
http://www.telerik.com/help/aspnet-ajax/treeview-onclientnodeclicked.html

I have a databound RADTreeView and what i'm looking for is something to get the value of the clicked node that is internal to the Tree and not displayed. I'm not sure whether this is stored in DataValueField or DataFieldId. What I'm storing is a unique key in the db and I need it to make queries in the
OnClientNodeClicked="ClientNodeClicked"
of RADTree

is there such a method as get_value() or similar?

Nevermind, get_value() was returning null values, it is working fine now. 




Thank you, 
regards,
awni
Tags
TreeView
Asked by
Balamurali Venkatesan
Top achievements
Rank 1
Answers by
Yana
Telerik team
awni
Top achievements
Rank 1
Plamen
Telerik team
Share this question
or