The Syncfusion native Blazor components library offers 70+ UI and Data Viz web controls that are responsive and lightweight for building modern web apps.
.NET PDF framework is a high-performance and comprehensive library used to create, read, merge, split, secure, edit, view, and review PDF files in C#/VB.NET.
RRRamya R Syncfusion Team March 28, 2007 09:23 AM UTC
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\4.4.0.51\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) this.CalculateSubNodeCount(expsymbol);
// Create diagram symbol nodes for each employee and initialize the diagram this.CreateOrgDiagramFromList(sortedlist);
htemployees.Clear(); sortedlist.Clear(); }
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); sqlConn.Open(); 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 sqlReader.Close(); // Close the connection sqlCommand.Connection.Close();
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.