dhtymlXtree with .NET connctor

Hi All,

I’m new to dhmlxTree and .NET connector. I’m trying to populating the tree by using .NET connector.

I have 3 tabels in SQL which are “country”, “state” and “city”. I have made my table as simpel as possibe, the schemas are as below:

“country”: country_id, country_name
“state”: state_id, state_name, country_id
“city”: city_id, city_name, state_id

Is there any sample code which demonstrates how to populate the xTree by using .NET connector?

I did spend a lot of time, but the sample I have found are only for 2 levels hierarchy instsead of more levels.

Thanks in advance,

Chen Wei

Hello,
you can use dhtmlxTreeMultitableConnector, it allows to use different tables for levels of the tree.
The code may be like following:[code] public override IdhtmlxConnector CreateConnector(HttpContext context)
{
var connector = new dhtmlxTreeMultitableConnector(
dhtmlxDatabaseAdapterType.SqlServer2005,
ConfigurationManager.ConnectionStrings[“SamplesDatabase”].ConnectionString
);

        connector.MaxLevel = 2;
        int level = connector.GetLevel(context.Request);
        switch (level)
        {

            case 0:
                connector.RenderQuery("country", "country_id", "", "country_name");
                break;
            case 1:
                connector.RenderQuery("state", "state_id", "country_id", "state_name");
                break;
            case 2:
                connector.RenderQuery("city", "city_id", "state_id", "city_name");
                break;

        }
        return connector;
    }[/code]connector.RenderQuery takes 4 parameters - table name(it can also take sql query), primari key column, foreign key, dispayed text,

Hi Aliaksandr,

A late “thanks” from me.

Many thanks for your reply. I have managed to solve it by constucting a XML string from my ASP.NET generic handler. I will keep ypur sample code for my futrue reference.

Chen Wei