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. Image for the cookie policy date
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to bind XML data to TreeGrid

Platform: ASP.NET Web Forms |
Control: TreeGrid

It is possible to bind XML data to TreeGrid by using ParentIdMapping and IdMapping properties, where the xml tags must be mapped as fields in TreeGrid columns. Please refer the below code snippets for importing XML data into TreeGrid.

Code snippets:

In Default.aspx:

      <form id="Form1" runat="server" onsubmit="return false">
        <ej:TreeGrid runat="server" ID="TreeGridControlEditing" IdMapping="Id"   
                <ej:TreeGridColumn HeaderText="Task Id" Field="Id" Width="55" EditType="Numeric"/>
                <ej:TreeGridColumn HeaderText="Task Name" Field="Name" EditType="String"/>
                <ej:TreeGridColumn HeaderText="Start Date" Field="StartDate" EditType="Datepicker"/>
                <ej:TreeGridColumn HeaderText="End Date" Field="EndDate" EditType="Datepicker"/>
                <ej:TreeGridColumn HeaderText="Duration" Field="Duration" EditType="Numeric" />
                <ej:TreeGridColumn HeaderText="Progress" Field="PercentDone" EditType="Numeric"/>

In XML file:

<?xml version="1.0" encoding="utf-8" ?>
  <Name>Planning Schedule</Name> 
              <Name>Plan Timeline</Name> 

In Default.aspx.cs:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
namespace TreeGrid
    public partial class _Default : Page
        protected void Page_Load(object sender, EventArgs e)
            DataSet data = new DataSet();
            this.TreeGridControlEditing.DataSource = data;

Please find the demo sample link below for XML databinding in TreeGrid

XML databinding

2X faster development

The ultimate ASP.NET Web Forms UI toolkit to boost your development speed.
You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

Warning Icon 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.Close Icon

Live Chat Icon For mobile