We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

TreeView Node''s Treeview

Thread ID:

Created:

Updated:

Platform:

Replies:

71589 Feb 6,2008 02:38 PM Feb 15,2008 08:33 AM ASP.NET Web Forms (Classic) 4
loading
Tags: Tools
Kathy Gray
Asked On February 6, 2008 02:38 PM

on the Server Side, how would I get the Treeview ID of a node? I have the node, and I want to know what TreeView it belongs to.


Vishnu Kumar [Syncfusion]
Replied On February 7, 2008 07:15 AM

Hi Jan,

Thank you for your patience.

Issuehow would I get the Treeview ID of a node?

You can get the treeview id and node belogs to the treeview using the below code snippet :


protected void TreeView1_NodeSelected(object sender, TreeViewNodeEventArgs e)
{
if (e.Node.ID != "M1")
{
lblEvent.Text = "Selected Node ID:" + " " + e.Node.ID + "," + " " + "Selected Node Treeview ID Is :" + TreeView1.ID + "";
Label1.Text = "Selected Node Parent ID:" + " " + e.Node.ParentNode.ID + "";
}

}


Please refer the sample in the below link which illustrates the above:

http://websamples.syncfusion.com/samples/Tools.Web/6.1.0.34/71589/main.htm

Please try running the above sample and let me know if this helps.

Regards,
Vishnu.



Kathy Gray
Replied On February 10, 2008 04:17 PM

But, how do I know that e.node belongs to treeview1? What if there are more than one treeview on the page?


Vishnu Kumar [Syncfusion]
Replied On February 13, 2008 08:06 AM

Hi Jan,

Thank you for your patience.

Issue:how do I know that e.node belongs to treeview1? What if there are more than one treeview on the page?

You can get the treeview id and node belongs to the treeview by using Treeview node selected event. The following code snippet is used to achieve this behavior:


Treeview 1 :

protected void TreeView1_NodeSelected(object sender, TreeViewNodeEventArgs e)
{
if (e.Node.ID != "M1")
{
lblEvent.Text = "Selected Node ID:" + " " + e.Node.ID + "," + " " + "Selected Node Treeview ID Is :" + TreeView1.ID + "";
Label1.Text = "Selected Node Parent ID:" + " " + e.Node.ParentNode.ID + "";
}

}

Treeview 2 :
protected void TreeView2_NodeSelected(object sender, TreeViewNodeEventArgs e)
{
if (e.Node.ID != "M1")
{
lblEvent.Text = "Selected Node ID:" + " " + e.Node.ID + "," + " " + "Selected Node Treeview ID Is :" + TreeView2.ID + "";
Label1.Text = "Selected Node Parent ID:" + " " + e.Node.ParentNode.ID + "";
}
}



Please refer the modified sample in the below link which illustrates the above:

http://websamples.syncfusion.com/samples/Tools.Web/6.1.0.34/71589/main.htm

Please try running the above sample and let me know if this helps.

Regards,
Vishnu.



Nandakumar R [Syncfusion]
Replied On February 15, 2008 08:33 AM


Hi,

I regret for the inconvenience caused.

Normally in an event, the sender will be the control itself. So, you can get the instance of the control by triggering an event in the node and get the ID of that. Please try the below code and let me know if this helps.
    protected void TreeView1_NodeCheckChanged(object sender, Syncfusion.Web.UI.WebControls.Tools.TreeViewNodeEventArgs e)
{
Syncfusion.Web.UI.WebControls.Tools.TreeView _treeViewObj = sender as Syncfusion.Web.UI.WebControls.Tools.TreeView;
Response.Write(_treeViewObj.ID.ToString());
}

Thank you for your interest in Syncfusion Essential Studio.

Regards,
Nanda


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;