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

trying to get the datafieldID value back from Tree on Nodeselect

2 Answers 125 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Bruce St.Clair
Top achievements
Rank 2
Bruce St.Clair asked on 15 Sep 2008, 07:41 PM

I am tring to get the value of the DataValueID that I used to build the tree when nodeselcted is fired.  I get the text back but cant seem to get the orignal ID back.  Any Ideas?

Code Snippet.

       protected override void OnInit(EventArgs e)
        {
            RadTreeView1.Nodes.Clear();
            DataAccess.DA dt = new DA("Connection string");
            DB.m_da = dt;

            try
            {
                DataSet dsp = new DataSet();
                DB.m_da.SetRead("SELECT 'All Providers' AS [Name], '0' AS [ID], null as tree union SELECT [FName] + ' ' + [LName] AS [Name], [ID],0 as [Tree] FROM Provider WHERE [Inactive] = 0 ORDER BY 1", 1);
                DB.m_da.Run(ref dsp);

                RadTreeView1.DataSource = dsp;

                RadTreeView1.DataFieldID = "ID";
                RadTreeView1.DataTextField = "Name";
                RadTreeView1.DataFieldParentID = "Tree";

                RadTreeView1.DataBind();

                RadTreeView1.ExpandAllNodes();
                RadTreeView1.MultipleSelect = true;
                RadTreeView1.CheckBoxes = true;

            }
            catch (Exception ex)
            {
                string s = ex.Message;
            }
        }

        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            Label1.Text = "Providers Saved";
            System.Collections.Generic.IList<RadTreeNode> providercheck = RadTreeView1.CheckedNodes;
        }

        protected void RadTreeView1_NodeCheck(object sender, RadTreeNodeEventArgs e)
        {

            string check = e.Node.CheckState.ToString();
            //string provider = e.Node
            System.Collections.Generic.IList<RadTreeNode> providercheck = RadTreeView1.CheckedNodes;

 

 

            // DataSet dsp = new DataSet();
            // DB.m_da.SetRead("", 1);
            // DB.m_da.Run(ref dsp);
        }
}

2 Answers, 1 is accepted

Sort by
0
Accepted
Atanas Korchev
Telerik team
answered on 16 Sep 2008, 06:20 AM
Hi Bruce St.Clair,

DataFieldID is used only to create the hierarchy during databinding. You can use the DataValueField property to provide data for the Value property. Then use the value to access the associated id:

RadTreeView1.DataFieldID = "ID";
RadTreeView1.DataValueField = "ID";

Kind regards,
Albert
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Bruce St.Clair
Top achievements
Rank 2
answered on 17 Sep 2008, 02:26 PM
Thank you very much that was the golden answer
Tags
TreeView
Asked by
Bruce St.Clair
Top achievements
Rank 2
Answers by
Atanas Korchev
Telerik team
Bruce St.Clair
Top achievements
Rank 2
Share this question
or