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.
Unfortunately, activation email could not send to your email. Please try again.


Thread ID:





58683 Mar 26,2007 05:28 PM Mar 28,2007 05:23 AM ASP.NET Web Forms (Classic) 1
Tags: DiagramWebControl
john eid
Asked On March 26, 2007 05:28 PM


I downloaded the eval version and trying to create a expander according to the infomration in my database. I have couple questions.

1)The sample i see is reading from XML. How can i read the data directly from SQL? is it possible and what is the table format if it is possible?

2) where can i find the sample code to create the diagram with the default symbol? what method is called to create symbol and connector?



Ramya R [Syncfusion]
Replied On March 28, 2007 05:23 AM

Hi Eva,

Thanks for your interest in Essential Diagram.

With regard to your first query, Yes, it is possible to access the data from SQL Database and create nodes.
Kindly take a look at the code snippet below and add it to the Expander sample(Syncfusion\Essential Studio\\Web\diagram.web\Samples\2.0\Expander) and call the InitializeDiagramFromDatabase() method under the PageLoad event and comment the call for InitializeDiagramFromXMLData() method under the PageLoad event.

protected void InitializeDiagramFromDatabase()

// Read data from the SQL database and populate a Hashtable using the employee ID as the key
Hashtable htemployees = this.ReadEmployeeDataFromDatabase();

// Create a manager-employee nested list with top-level employees forming the root nodes
ArrayList sortedlist = this.GetSortedEmployeesList(htemployees);

foreach (ExpanderSymbol expsymbol in sortedlist)

// Create diagram symbol nodes for each employee and initialize the diagram


protected Hashtable ReadEmployeeDataFromDatabase()
Hashtable htemployees = new Hashtable();
string connString = "user id=;pwd=;data source=;persist security info=False;initial catalog=Employees";
SqlConnection sqlConn = new SqlConnection(connString);
string selectquery = "SELECT EmployeeID, Name, ManagerID FROM Employees";
SqlCommand sqlCommand = new SqlCommand(selectquery, sqlConn);
SqlDataReader sqlReader = sqlCommand.ExecuteReader();
// Extract employee data from the reader
while (sqlReader.Read())
object[] employeedata = new object[3];
int count = sqlReader.GetValues(employeedata);

// Create an Employee instance to represent each employee
ExpanderSymbol emply = new ExpanderSymbol();
emply.EmployeeID = employeedata[0].ToString();
emply.EmployeeName = (string)employeedata[1];
if (count == 3)
emply.ManagerID = employeedata[2].ToString();

htemployees.Add(emply.EmployeeID, emply);
// Close the reader
// Close the connection

return htemployees;

I have attached the AccessFormat of the Database which I have used in the above code snippet. Kindly import it to SQL Database Collection using the EnterpriseManager before adding the above code snippet to the Expander sample.

Now the run the Expander sample, the output appears with the nodes created using the data in database.

Let me know whether this helps you.

Regarding your second query, could please provide me with some more information with regard to the condition that you have mentioned here, so that it would help us in meeting your requirement exactly.

Thanks & Regards,


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

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.