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

Binding to linq anonymous type

1 Answer 73 Views
DropDownTree
This is a migrated thread and some comments may be shown as answers.
Scott
Top achievements
Rank 1
Scott asked on 21 Apr 2015, 10:04 AM

Hi,

 

Im having an issue trying to bind to a linq anonymous type. I can bind find as long as i don't specify a 'DataFieldParentID', if i specify that DataFieldParentID then the dropdowntree control just displays no items.

So if i comment out the line below: rdt.DataFieldParentID = "ParentID"; then the control loads fine with the options i expect and i am able to select and use them fine, it simply seems to be an issue when trying to create a hierarchy. 

My drop down tree control is inside a RadListView and i am binding on the ItemDataBound event, my code for binding if the following:             

var x = from y in services select new { ID = y.ID, ParentID = y.PrimaryWorkType.ID, myText = y.Description};
 
RadDropDownTree rdt = (RadDropDownTree)e.Item.FindControl("ddlAffectedServices");
 
rdt.DataTextField = "myText";
rdt.DataValueField = "ID";
rdt.DataFieldID = "ID";
rdt.DataFieldParentID = "ParentID";
rdt.DataSource = x;
rdt.DataBind();

 

1 Answer, 1 is accepted

Sort by
0
Plamen
Telerik team
answered on 23 Apr 2015, 06:31 AM
Hi Scott,

In such case the important thing is that some of the nodes have parent id value set to zero( or null) so that the root nodes are build correctly exactly as it is described in the similar scenario in RadTreeView control here.

Hope this information will help you solve the issue.

Regards,
Plamen
Telerik
 

See What's Next in App Development. Register for TelerikNEXT.

 
Tags
DropDownTree
Asked by
Scott
Top achievements
Rank 1
Answers by
Plamen
Telerik team
Share this question
or