I already said how to populate from database
i will give you one example
Create table with column names
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[OrgChart](
[Parent] [varchar](200) NULL,
[Subordinate] [varchar](200) NULL,
[Desn_name] [varchar](300) NULL
) ON [PRIMARY]
GO
I will give some sample data also, in the below sample A is head of every one so only for the first Boss u have to 0(zero) in Parent column.
0 |
A |
CEO |
A |
B |
MD |
B |
C |
IT Head |
B |
D |
HR Head |
C |
E |
Systems Administrator |
C |
F |
Systems Administrator |
D |
G |
HR Assistant |
D |
H |
HR Assistant |
Note: The first row in above table is 0 A CEO
then in code
protected void Page_Load(object sender, EventArgs e)
{
// Change the response headers to output a JPEG image.
this.Response.Clear();
this.Response.ContentType = "image/jpeg";
//Build the image
//In real life this can be done using parameters
OrgChartGenerator.OrgChart myOrgChart;
OrgChartGenerator.OrgData.OrgDetailsDataTable myOrgData =
new OrgChartGenerator.OrgData.OrgDetailsDataTable();
SqlCommand cmd = new SqlCommand("SELECT * from OrgChart", Con);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataTable dt = new DataTable();
da.Fill(dt);
if ((dt != null) && dt.Rows.Count > 0) {
foreach (DataRow dr in dt.Rows) {
myOrgData.AddOrgDetailsRow(dr[1].ToString(), "", dr[0].ToString(), dr[2].ToString());
}
myOrgData.AcceptChanges();
myOrgChart = new OrgChartGenerator.OrgChart(myOrgData);
myOrgChart.BGColor = System.Drawing.ColorTranslator.FromHtml("#DEDCDD");
myOrgChart.BoxWidth = 90;
myOrgChart.BoxHeight = 65;
myOrgChart.FontSize = 8;
SqlCommand head = new SqlCommand("select [Subordinate] from OrgChart where Parent = '0'", Con);
System.Drawing.Image OC = System.Drawing.Image.FromStream(myOrgChart.GenerateOrgChart(head.ExecuteScalar(), System.Drawing.Imaging.ImageFormat.Jpeg));
OC.Save(this.Response.OutputStream, ImageFormat.Jpeg());
OC.Dispose();
}