Displaying Employees
SmartChart allows users to drill-down into an SmartChart. This example shows one way to drill-down by allowing users to click custom up and down arrow images. The images are defined using the HasParentImagePath and HasChildrenImagePath properties.

Org Chart
Michael Price
President/CEO













Karle Gordon
Chief Compliance Officer
Patricia Law
Chief Financial Officer
Cindy Meredith
Dir of Business Development
B. David Robinson
Medical Director
William Roush
Clinical Director Home Care
Renae Tolson
Director of Human Resources
Diane Tomasi
Chief Development Officer
Carol Vanderford
Clinical Dir. Inpatient Services
Laurie Ward
Executive Assistant
ASPX Code

<%@ Page language="c#" MasterPageFile="~/SampleCode/SamplesMasterPage.master" Inherits="SmartWebControls.SampleCode.OrgChartEmployees" CodeFile="OrgChartEmployees.aspx.cs" %>
<%@ Register TagPrefix="swc" Namespace="SmartWebControls" Assembly="SmartWebControls.SmartChart" %>
<asp:Content ID="content" runat="server" ContentPlaceHolderID="cphMain">
    <div id="divTitle">Displaying Employees</div>
    <div id="divInstructions">
        SmartChart allows users to drill-down into an SmartChart.  This example shows one way to drill-down by allowing users
        to click custom up and down arrow images.  The images are defined using the HasParentImagePath and HasChildrenImagePath
        properties.
    </div>
    <p></p>
    <asp:Label ID="lblOutput" runat="server" />
    <swc:SmartChartPro id="SmartChart1" title="Org Chart" runat="server" OutputType="Html" AllowDrillDown="True"
        DataTitleFields="name,title" font-size="8" MaxTextLength="30" 
        Width="850px" Height="300px" DataNodeName="Employee" DataKeyField="id" DataFields="name,title"
        BoxColor="Gainsboro" BoxGradient="True" ChartDepth="2" 
        font-bold="false" MaxChildrenPerLevelGroup="6" 
        HasParentImagePath="~/SampleCode/SmartChartPro/Images/up.gif" HasParentImageVSpace="6"
        HasChildrenImagePath="~/SampleCode/SmartChartPro/Images/down.gif" HasChildrenImageVSpace="0"
        DrillDownType="SmartChartImage"></swc:SmartChartPro>
</asp:Content>

C# Code:

using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Xml;
using System.IO;

namespace SmartWebControls.SampleCode {
    /// <summary>
    /// Summary description for Employees.
    /// </summary>
    public partial class OrgChartEmployees : System.Web.UI.Page {
    
        protected void Page_Load(object sender, System.EventArgs e) {
            this.SmartChart1.SmartChartClicking += new EventHandler<SmartChartEventArgs>(this.SmartChart1_SmartChartClicking);

            if (!Page.IsPostBack) {
                SmartChart1.DataSource = GetDataSource();
                SmartChart1.DataBind();
            }
        }

        private DataSet GetDataSource() {
            DataSet ds = new DataSet();
            ds.ReadXml(Server.MapPath("~/SampleCode/SmartChartPro/XML/EmployeesFlatTable.xml"));
            ds.Tables[0].TableName = "Employee";
            DataColumn colParent = ds.Tables[0].Columns["id"];
            DataColumn colChild = ds.Tables[0].Columns["pid"];
            DataRelation relation = new DataRelation("ParentChildRel",colParent,colChild);
            relation.Nested = true;
            ds.Relations.Add(relation);
            return ds;

            //Loading DataSet directly into an XmlDataDocument constructor can cause an error (object reference error)
            //when a large number of relationships are present.  This is a work around
            //to that issue.        
            /*
            MemoryStream ms = new MemoryStream();
            ds.WriteXml(ms); //Write to memorystream
            ms.Position = 0;
            XmlDocument doc = new XmlDocument();
            doc.Load(ms); //load memorystream into DOM
            ms.Close();
            return doc;
            */
        }

        private void SmartChart1_SmartChartClicking(object sender, SmartWebControls.SmartChartEventArgs e) {
            this.lblOutput.Text = "The item you clicked has an ID of: " + e.Item.DataKey;
        }


    }
}