How to get checked node details in an ASP.NET Web Forms TreeView?
In order to retrieve the checked node details of TreeView in the server-side, you can use CurrentCheckedNodes property that is available in the TreeView event argument object. This carries the checked node details to the server side.
CurrentCheckedNodes is the list type that carries the ID and Text of the checked nodes. You can get the values as given in the following code example.
ASPX
<div> <ej:TreeView ID="TreeView1" runat="server" ShowCheckbox="true" OnNodeChecked="sampleTreeview_NodeChecked"> <Nodes> <ej:TreeViewNode Id="node1" Text="Parent1"> <Nodes> <ej:TreeViewNode Id="subnode1" Text="Child1"></ej:TreeViewNode> <ej:TreeViewNode Id="subnode2" Text="Child2"></ej:TreeViewNode> <ej:TreeViewNode Id="subnode3" Text="Child3"></ej:TreeViewNode> </Nodes> </ej:TreeViewNode> <ej:TreeViewNode Id="node2" Text="Parent2"></ej:TreeViewNode> <ej:TreeViewNode Id="node3" Text=" Parent 3"></ej:TreeViewNode> </Nodes> </ej:TreeView> </div> <asp:Label ID="Label1" Text="Checked Nodes are:" runat="server"></asp:Label>
CS
protected void sampleTreeview_NodeChecked(object sender, Syncfusion.JavaScript.Web.TreeViewEventArgs e) { foreach (NodeData data in e.CurrentCheckedNodes) Label1.Text+= data.Id + "-" + data.Text+">"; }
The following screenshot displays the TreeView with checked node details.
Note
A new version of Essential Studio for ASP.NET is available. Versions prior to the release of Essential Studio 2014, Volume 2 will now be referred to as a classic versions.The new ASP.NET suite is powered by Essential Studio for JavaScript providing client-side rendering of HTML 5-JavaScript controls, offering better performance, and better support for touch interactivity. The new version includes all the features of the old version, so migration is easy.
The Classic controls can be used in existing projects; however, if you are starting a new project, we recommend using the latest version of Essential Studio for ASP.NET. Although Syncfusion will continue to support all Classic Versions, we are happy to assist you in migrating to the newest edition.
For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our other controls. If you have any queries or require clarifications, please let us know in the comments section below.
You can also contact us through our support forums, Direct-Trac, or feedback portal. We are always happy to assist you!