Getting Started with ASP.NET Core DropDownTree Control
23 Jul 20264 minutes to read
This section briefly explains how to include the ASP.NET Core DropDownTree control in your ASP.NET Core application using Visual Studio.
Create an ASP.NET Core Web App with Razor pages
Create an ASP.NET Core Web App using Visual Studio via Microsoft Templates or the ASP.NET Core Extension. For detailed instructions, refer to the ASP.NET Core Web App Getting Started documentation.
Install the required ASP.NET Core packages
To add ASP.NET Core DropDownTree control in the app, open the NuGet package manager in Visual Studio (Tools → NuGet Package Manager → Manage NuGet Packages for Solution), search for and install the Syncfusion.AspNetCore.Navigations and Syncfusion.AspNetCore.Themes packages. All Syncfusion ASP.NET Core packages are available on nuget.org. See the NuGet packages topic for details.
Alternatively, you can install the same packages using the Package Manager Console with the following command.
Install-Package Syncfusion.AspNetCore.Navigations -Version 34.1.29
Install-Package Syncfusion.AspNetCore.Themes -Version 34.1.29Add ASP.NET Core Tag Helpers
After the packages are installed, open the ~/Pages/_ViewImports.cshtml file and import the Syncfusion.AspNetCore.Base and Syncfusion.AspNetCore.Navigations Tag Helpers.
@addTagHelper *, Syncfusion.AspNetCore.Base
@addTagHelper *, Syncfusion.AspNetCore.NavigationsAdd stylesheet and script resources
The theme stylesheet and script can be referenced from CDN. Include the stylesheet and script references inside the <head> of ~/Pages/Shared/_Layout.cshtml.
<head>
...
@* ASP.NET Core controls styles *@
<link rel="stylesheet" href="_content/Syncfusion.AspNetCore.Themes/styles/fluent2.css" />
@* ASP.NET Core controls scripts *@
<script src="_content/Syncfusion.AspNetCore.Navigations/scripts/sf-drop-down-tree.min.js"></script>
</head>Register the Script Manager
Open the ~/Pages/Shared/_Layout.cshtml file and register the script manager <ejs-scripts> at the end of the <body> element as follows.
<body>
...
@* ASP.NET Core Script Manager *@
<ejs-scripts></ejs-scripts>
</body>Add ASP.NET Core DropDownTree control
Add the ASP.NET Core DropDownTree control in the ~/Pages/Index.cshtml file.
<ejs-dropdowntree id="data">
</ejs-dropdowntree>Run the application
Press Ctrl+F5 (Windows) or ⌘+F5 (macOS) to launch the application. The ASP.NET Core DropDownTree control will render in your default web browser.

Binding data source
The Dropdown Tree control can load the data either from local data sources or remote data services. This can be done using the dataSource property that is a member of the fields property. The dataSource property supports nested list of data and DataManager. Here, nested list of data is passed to the Dropdown Tree control.
@{
ViewData["Title"] = "Home page";
List<Parent> parentitem = new List<Parent>();
List<Child> childitem = new List<Child>();
parentitem.Add(new Parent
{
nodeId = "01",
nodeText = "Music",
nodeChild = childitem,
});
childitem.Add(new Child { nodeId = "01-01", nodeText = "Gouttes.mp3" });
List<Child> childitem2 = new List<Child>();
parentitem.Add(new Parent
{
nodeId = "02",
nodeText = "Videos",
expanded=true,
nodeChild = childitem2,
});
childitem2.Add(new Child { nodeId = "02-01", nodeText = "Naturals.mp4" });
childitem2.Add(new Child { nodeId = "02-02", nodeText = "Wild.mpeg"});
List<Child> childitem3 = new List<Child>();
parentitem.Add(new Parent
{
nodeId = "03",
nodeText = "Documents",
nodeChild = childitem3,
});
childitem3.Add(new Child { nodeId = "03-01", nodeText = "Environment Pollution.docx" });
childitem3.Add(new Child { nodeId = "03-02", nodeText = "Global Water, Sanitation, & Hygiene.docx"});
childitem3.Add(new Child { nodeId = "03-03", nodeText = "Global Warming.ppt" });
childitem3.Add(new Child { nodeId = "03-04", nodeText = "Social Network.pdf" });
childitem3.Add(new Child { nodeId = "03-05", nodeText = "Youth Empowerment.pdf"});
char[] value = { 'n','o','d','e','C', 'h', 'i', 'l', 'd' };
string child = new string(value);
}
<div style="margin:0 auto; width:250px;">
<ejs-dropdowntree id="treedata" placeholder="Select a Item">
<e-dropdowntree-fields dataSource="parentitem" child="child" value="nodeId" text="nodeText"></e-dropdowntree-fields>
</ejs-dropdowntree>
</div>public class Parent
{
public string nodeId;
public string nodeText;
public string icon;
public bool expanded;
public bool selected;
public List<Child> nodeChild;
}
public class Child
{
public string nodeId;
public string nodeText;
public string icon;
public bool expanded;
public bool selected;
public List<Child> nodeChild;
}
NOTE