I HAVE FIELD LIKE THIS
USERNAME NAME POSITION
ABC SDSD MANAGER
XYZ DSD EMPLOYEE
GHF SD MANAGER
GH DD DIRECTOR
LIKE THIS AND I WANT TO RETRIEVE HIERARCHICAL RELATION BETWEEN THEM IN THE FORM - NAME & UPPERPOST
I HAVE CODE FOR ORG CHAT SOMETHING LIKE THIS...
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js" type="text/javascript"></script>
<script type="text/javascript" src="//www.google.com/jsapi"></script>
<script type="text/javascript">
google.load('visualization', '1', { packages: ['orgchart'] });
</script>
<script type="text/javascript">
$(document).ready(function () {
$.ajax({
type: 'POST',
dataType: 'json',
contentType: 'application/json',
url: 'Default.aspx/GetData',
data: '{}',
success:
function (response) {
drawVisualization(response.d);
}
});
})
function drawVisualization(datavalues) {
var data = google.visualization.DataTable();
data.addColumn('string', 'Name');
data.addColumn('string', 'Manager');
data.addColumn('string', 'ToolTip');
for (var i = 0; i < dataValues.length; i++) {
data.addRow([dataValues[i].ColumnName, dataValues[i].Value]);
}
new google.visualization.OrgChart(document.getElementById('visualization')).
draw(data, { allowHtml: true });
}
</script>
BEHIND IT
ASPX.CS
[WebMethod]
public static List
GetData()
{
SqlConnection conn = new SqlConnection(""SDSDS);
DataSet ds = new DataSet();
DataTable dt = new DataTable();
conn.Open();
string cmdstr = "select top 5 Country, COUNT(CompanyName) [Total Suppliers] from [Suppliers] group by Country";
SqlCommand cmd = new SqlCommand(cmdstr, conn);
SqlDataAdapter adp = new SqlDataAdapter(cmd);
adp.Fill(ds);
dt = ds.Tables[0];
List dataList = new List();
string cat="";
int val=0;
foreach (DataRow dr in dt.Rows)
{
cat=dr[0].ToString();
val=Convert.ToInt32( dr[1]);
dataList.Add(new Data(cat, val));
}
return dataList;
}
}
public class Data
{
public string ColumnName = "";
public int Value = 0;
public Data(string columnName, int value)
{
ColumnName = columnName;
Value = value;
}
}
I NEED QUERY THAT WILL PASS MY VALUE TO CODE
TAHNX IN ADVANCE