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.

Diagram

Thread ID:

Created:

Updated:

Platform:

Replies:

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

Hi,

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?


Thanks,

Eva

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\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.


Thanks & Regards,
Ramya.


CONFIRMATION

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.

;