Displaying Employee Pictures
The SmartChartLite control allows users to drill-down into a chart and can also display pictures. This example shows one way to drill-down by allowing users to click items displayed in the chart.


ACME Corp 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
Suyama Roush
Clinical Director Home Care
Greg Tolson
Director of Human Resources
Diane Tomasi
Chief Development Officer
Dan Vanderford
Clinical Dir. Inpatient Services
Laurie Ward
Executive Assistant




ASPX Code

<%@ Page language="c#" MasterPageFile="~/SampleCode/SamplesMasterPage.master" Inherits="SmartWebControls.SampleCode.EmployeePictures" CodeFile="EmployeePictures.aspx.cs" %>
<%@ Register TagPrefix="swc" Namespace="SmartWebControls" Assembly="SmartWebControls.SmartChart" %>
<asp:Content ID="content" runat="server" ContentPlaceHolderID="cphMain">
    <div id="divTitle">Displaying Employee Pictures</div>
    <div id="divInstructions">
        The SmartChartLite control allows users to drill-down into a chart and can also display pictures.  This example shows one way to drill-down by allowing users
        to click items displayed in the chart.
    </div>
    <p></p>
    <asp:Label ID="lblOutput" runat="server" />
    <br />
    <swc:SmartChartLite id="SmartChart1" title="ACME Corp Org Chart" runat="server" OutputType="Html" AllowDrillDown="True"
        DataTitleFields="name,title" font-size="8" MaxTextLength="30"
        Width="800px" Height="300px" DataNodeName="Employee" DataKeyField="id" DataFields="name,title"
        BoxColor="Gainsboro" BoxGradient="True" ChartDepth="2" ImageWidth="50" ImageHeight="50" ImageField="image" 
        font-bold="false" MaxChildrenPerLevelGroup="6" HasChildrenImageVSpace="3"
        DrillDownType="SmartChartItem" FitToWidth="true"></swc:SmartChartLite>
   <br /><br /><br /><br />
</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 EmployeePictures : 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/SmartChartLite/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;
        }


    }
}