Binding to linq anonymous type

2 posts, 0 answers
  1. Scott
    Scott avatar
    2 posts
    Member since:
    May 2014

    Posted 21 Apr 2015 Link to this post

    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();

     

  2. Plamen
    Admin
    Plamen avatar
    2729 posts

    Posted 23 Apr 2015 Link to this post

    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.

     
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top