Org Chart Binding Issue - Not Visible

2 posts, 0 answers
  1. kuntesh
    kuntesh avatar
    1 posts
    Member since:
    May 2014

    Posted 06 May 2014 Link to this post

    Hi

         I have done Programmatically Binding to the RadOrgChart with DataTable . But i am not able to see the chart on UI. Below is my Code


                DataTable table = new DataTable();
                table.Columns.Add("ID", typeof(String));
                table.Columns.Add("Title", typeof(String));
                table.Columns.Add("AndOr", typeof(String));
                table.Columns.Add("ParentID", typeof(String));
                table.Columns.Add("Designation", typeof(String));

                table.Rows.Add("1", "John Smith", "", "4", "CEO");
                table.Rows.Add("2", "Joe Robert", "Or", "1", "Manager SLS");
                table.Rows.Add("3", "Jack Kent", "Or", "1", "Manager Mkt");
                table.Rows.Add("4", "Ravi Kumar", "Or", "2", "Engineer");
                table.Rows.Add("5", "Sue Raymond", "And", "2", "Engineer");
                table.Rows.Add("6", "Lisa simpson", "Or", "4", "Junior Engineer");
                table.Rows.Add("7", "Bob Woley", "", "5", "Junior Engineer");
                table.Rows.Add("8", "Ron Jones", "", "3", "CSR");
                table.Rows.Add("9", "Dave Mason", "Or", "3", "CSR");
                table.Rows.Add("10", "John Williams", "", "3", "CSR");

                objRadOrgChart.DataTextField = "Title";
                objRadOrgChart.DataFieldID = "ID";
                objRadOrgChart.DataFieldParentID = "ParentID";      
                objRadOrgChart.DataSource = table;
                objRadOrgChart.DataBind();

                 This not Shows anything on Page . But when i remove DataFieldParentID  , It shows all records with chart . Please help how it wants the data to show the chart on Page
  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 06 May 2014 in reply to kuntesh Link to this post

    Hi kuntesh,

    DataFieldParentID of RadOrgChart is holding the name of the DataColumn of ParentID value. In order to Show any node as parent you need to set the ParentId of that particular node to null and the child nodes ParentId is the Id of the ParentNode. Please do the following modification in your code which works fine at my end.

    C#:
    protected void Page_Load(object sender, EventArgs e)
    {
        DataTable table = new DataTable();
        table.Columns.Add("ID", typeof(String));
        table.Columns.Add("Title", typeof(String));
        table.Columns.Add("AndOr", typeof(String));
        table.Columns.Add("ParentID", typeof(String));
        table.Columns.Add("Designation", typeof(String));
     
        table.Rows.Add("1", "John Smith", "", null, "CEO");
        table.Rows.Add("2", "Joe Robert", "Or", "1", "Manager SLS");
        table.Rows.Add("3", "Jack Kent", "Or", "1", "Manager Mkt");
        table.Rows.Add("4", "Ravi Kumar", "Or", "2", "Engineer");
        table.Rows.Add("5", "Sue Raymond", "And", "2", "Engineer");
        table.Rows.Add("6", "Lisa simpson", "Or", "4", "Junior Engineer");
        table.Rows.Add("7", "Bob Woley", "", "5", "Junior Engineer");
        table.Rows.Add("8", "Ron Jones", "", "3", "CSR");
        table.Rows.Add("9", "Dave Mason", "Or", "3", "CSR");
        table.Rows.Add("10", "John Williams", "", "3", "CSR");
     
        RadOrgChart2.DataFieldID = "ID";
        RadOrgChart2.DataFieldParentID = "ParentID";
        RadOrgChart2.DataTextField = "Title";
        RadOrgChart2.DataSource = table;
        RadOrgChart2.DataBind();
    }

    Thanks,
    Princy.
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top