using string in DataFieldID and DataFieldParentID

2 posts, 0 answers
  1. Taburetka Kekc
    Taburetka Kekc avatar
    10 posts
    Member since:
    Aug 2009

    Posted 11 Aug 2009 Link to this post

    Hello !

    i have a question , is it possible to use strings in radtreeview datasource as id's ?
    for example tweaked treeview demo from TreeView / Programmatic Data Binding (doesnt work) :
            
    internal class SiteDataItemString
            {
                private string _text;
                private string _id;
                private string _parentId;

                public string Text
                {
                    get { return _text; }
                    set { _text = value; }
                }


                public string ID
                {
                    get { return _id; }
                    set { _id = value; }
                }

                public string ParentID
                {
                    get { return _parentId; }
                    set { _parentId = value; }
                }

                public SiteDataItemString(string id, string parentId, string text)
                {
                    _id = id;
                    _parentId = parentId;
                    _text = text;
                }
            }


            private void BindToIEnumerable(RadTreeView treeView)
            {
               List<SiteDataItemString> siteData = new List<SiteDataItemString>();

                siteData.Add(new SiteDataItemString("1", "0", "Products"));
                siteData.Add(new SiteDataItemString("2", "1", "RadControls for ASP.NET Ajax"));
                siteData.Add(new SiteDataItemString("3", "1", "RadControls for Silverlight"));

                treeView.DataTextField = "Text";
                treeView.DataFieldID = "ID";
                treeView.DataFieldParentID = "ParentID";
                treeView.DataSource = siteData;
                treeView.DataBind();
           }

    Thank You !
  2. Veselin Vasilev
    Admin
    Veselin Vasilev avatar
    2992 posts

    Posted 11 Aug 2009 Link to this post

    Hi Taburetka Kekc,

    Just set the ParentID to null:

    siteData.Add(new SiteDataItemString("1"null"Products")); 


    Sincerely yours,
    Veselin Vasilev
    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.
Back to Top